Open xls file from xls file in same session

A

Andrea

Hi all,
I've an excel-macro (in a Excel-file, say "A") which create a new excel-file
(say "B"); at end of macro (in file A) I open new file (B) created with:
shell(path_xls & " " & new_xlsfile)

where new_xlsfile contains path and name of my new xls file, and path_xls is
like:
C:\Programmi\MicrosoftOffice2003\Office11\excel.exe

All works fine, but new file is open in a "new excel session", so isn't
possible use function like "copy or move worksheet" from new file (B) to
other opened files (for ex, to A).

My question: there is a way to open my new file (B) in same "excel-session"
of caller-file (B)?
Thanks in advance
JFM
 
J

John Coleman

Use Woorkbooks.Open:

WorkBooks.Open(path_xls & " " & new_xlsfile)

should do it - then workbook B will be part of the workbooks
collection.
The notion you were getting at with "excel sessions" is often called
"instance" - you want both workbooks open in the same instance of the
application object.

Hope that helps

-John Coleman
 
A

Andrea

Hi John,
thanks very much, you solved my problem; your solution is exactly what I'm
looking for and is working fine!
And thanks also for your specification about notion of "instance".
Thanks very much again! Have a nice sunday.
JFM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top