If a program that has it's object model exposed via VBA is already running, how can you get a reference to that object model without creating your own instance?
Sub startword()
On Error Resume Next 'ignore errors
Set wordapp = GetObject(, "Word.Application"
If Err.Number <> 0 Then
Set wordapp = CreateObject("word.application"
End If
Err.Clear ' Clear Err object in case error occurred.
On Error GoTo 0 'Resume normal error processing
End Sub
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
You have added a reference to this other program in Project/References?
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
The choice of starting a new instance or use an already running instance of a COM server lies in the architecture created by the programmer of the COM server. You as a client cannot determine whether or not you will get a completely new instance of the server.
Otherwise it wouldn't be of much use to have the ability of choosing the instance creation as a programmer of a COM server.
Also I do not think that it is possible to get a reference to an already running COM server if you are not the client that started it. This would mean that you could run in serious trouble if you were the client that started the COM server in the first place. I cannot imagine that COM will be kind enough to just hand you an interface to a COM object that another client created.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.