Finding Excel application handle
Hi Mark,
GetObject is used to find "running programs" and creates a "handle" to the
object. (object or instance)
If the program is not running it will create a new object.
The second example I posted is right out of VB6 and does all the proper
error checking.
It tests to see if Excel is running and if it is it assigns an object name
to it. (MyXL)
The only "problem" with the code is it will not find more than 1 instance.
Or perhaps I should say it stops after finding the first instance.
The code I pointed to with the previous link will find all running instances
of Excel and if you un-comment the optional line it will find all running
programs on the machine.
I'm not sure what your programing level is so please don't take this the
wrong way.
If you open 2 notepad.exe "sessions" they are considered seperate instances.
That is they run in the own seperate "memory space".
Excel fights most attempts at this. Probably because the designers figured
it uses a lot of memory and other resources.
Excel is a MDI or Mulitpul Document Interface where you can have more than
one workbook open in 1 Excel instance and they can share resources.
The only way I know of to get a seperate instance of Excel is to open Excel
from the Startrun button or using VBA's Shell command to do the same.
Shell "start " & path & filename
--
John
johnf 202 at hotmail dot com
"Mark Grimes" wrote in message
...
| Hi John,
|
| I think that we're at cross-purposes here.
|
| The code that is run does not create the other instances of Excel,
| therefore your example needs to remove the GetObject() calls.
|
| The code needs to find the Excel objects that were created by other
applications or
| by someone opening up an instances of Excel.
|
| Any ideas much appreciated.
|
| Cheers,
| Mark.
|