Open SECOND Excel file....

alexdaman
03-24-2003, 12:41 PM
Hi all!
Simple question:

What do I have to do to open a SECOND excel file?
---
Dim xlap As New excel.Application 'Opens 1 excel appl.

sub open_excelfile()
xlap.Workbooks.Open "C:\file1.xcl" 'Open's 1st excel file
end sub

sub close_excelfile()
xlap.Workbooks.Close
xlap.Quit
Set xlap = Nothing
end sub

sub select_ragne()
xlap.Range("A1:A6").Select
end sub
---

If I declare a new object like:

Dim xlap_second As New excel.Application

it will start a new Excel, just for this second file
and this is a waste of memory.

Is it possible to open a NEW WORKBOOK?
I've seen that the property "Workbooks" has an index.
But I havent figured out how it works.

Thanks for any help!
Stay cool.

Mikecrosoft
03-24-2003, 12:49 PM
Use:

xlap.WorkBooks.Add .......

to add new workbooks to the same Excel Application, even I recomend first find current opened Excel instances before open a new one, look my Excel sample :) it uses GetObject and CreateObject functions.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum