Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the Windows Running Object table

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
This code was included in some Microsoft Access help about using Access as an automation server. The example starts up Excel. The main code checks for an existing instance with this line of code:

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

After error checking, it then invokes the following sub. What is it actually doing and what is the impact if I don't include such code in my own automation projects?

Thanks in advance for any help you can give me!

************************** Begin Code *******************
'Procedure dectects running Excel instance and registers it
Private Sub DetectExcel()
Const WM_USER = 1024
Dim hWnd As Long
'If Excel is running this API call returns its handle
hWnd = FindWindow("XLMAIN", 0)
If hWnd = 0 Then '0 means Excel not running
Exit Sub
Else
'Excel is running so use the SendMessage API
'function to enter it in the Running Object Table
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Sub 'DetectExcel
************************** End Code *********************


 
I think it has something to do with registering COM components. Better off leaving it there.

I REALLY hope that helps.
Will
 
SBendBuckeye

I never use that, but I think the function search for Excel and than define/create a (user) private message by sending WM_USER + 18 so it can talk to each other in a unique way.
Look here:

I don't know what your application is doing. If you don't use an internal ways to comunicate between application, you may get rid of it, since it has no effect if you just open, show and close Excel. But don't do it if you don't know what is going on

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top