How To: Get hWnd from a Process ID

K

Kevin McCartney

Hi Michel
Thanks for your help but what happens if I have several
Excel sessions running how do I now which one is the one
I'm looking for to destroy?

I'd really like to be able to pass the Process ID to a
function. Do you know of function that allows this?

Thanks for your time
KM
 
D

Dan Artuso

Hi,
You might want to use a function such as this to 'set' your excel variable.
If an instance of excel is already running, it will use that, otherwise it creates
a new instance.

Function InitializeExcel() As Boolean

On Error Resume Next
Set golApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set golApp = CreateObject("Excel.Application")
On Error GoTo Init_Err
End If

InitializeExcel = True
Init_Bye:

Exit Function
Init_Err:
InitializeExcel = False
Resume Init_Bye

End Function
 

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