View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.winapi,microsoft.public.win32.programmer.kernel
TCook TCook is offline
external usenet poster
 
Posts: 22
Default Visible Instances of an Application

Hello All,

I am building something that needs to grab a certain instance of MS Excel.
Unfortunately, "GetObject" randomly chooses an instance and, therefore, is
not appropriate / robust enough by itself. In pseudo code, what I need is
below:

For each pProcess in Processes
If instr(pProcess.Name, "Excel") 0 And pProcess.Visible = True
Then
Set MyAppInstance = pProcess.Instance

Exit For
End If
Next pProcess

Thanks & Regards,

TC