Determine number of open excel files

G

gw.boswell

I have a macro in which I need to open a specific Excel file.
Unfortunately with the code below although I can open the file, whether
it is visible and can be accessed depends on how many other Excel files
are open. How can I determine how many excel files are already open

Set xlAppEval = GetObject(, "Excel.Application")

Set Model = GetObject("c:\EVAL.xls")

xlAppEval.Application.Visible = True
xlAppEval.Parent.Windows(3).Visible = True <== only works if 2 excel
files are already open.


Alternatively, is there a better way to open the specified as an OLE
object?

TIA,
Garry
 
D

dbahooker

if you have one open then you've got too many

excel is a disease run away while you still can
 
J

Jim Cone

Garry,
Dim lngX as Long
lngX = xlAppEval.Workbooks.Count
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


<[email protected]>
wrote in message
I have a macro in which I need to open a specific Excel file.
Unfortunately with the code below although I can open the file, whether
it is visible and can be accessed depends on how many other Excel files
are open. How can I determine how many excel files are already open

Set xlAppEval = GetObject(, "Excel.Application")
Set Model = GetObject("c:\EVAL.xls")

xlAppEval.Application.Visible = True
xlAppEval.Parent.Windows(3).Visible = True <== only works if 2 excel
files are already open.
Alternatively, is there a better way to open the specified as an OLE
object?

TIA,
Garry
 
G

gw.boswell

Jim,
You auggestion worked perfectly (which I'm sure you knew it would).
Thanks you very much. That makes my life a lot easier.
Garry
 
G

gw.boswell

Jim,
You suggestion worked perfectly (which I'm sure you knew it would).
Thanks you very much. That makes my life a lot easier.
Garry
 

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