ACC95: GetObject Sample Function Does Not Detect Excel 7.0Last reviewed: August 29, 1997Article ID: Q155201 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. The GetObject Function Example in online Help for Microsoft Access for Windows 95 states that you can use GetObject to test if a copy of Microsoft Excel is already running. This works fine with versions of Microsoft Excel earlier than version 7.0. However, because Microsoft Excel version 7.0 does not register itself in the running object table (ROT) by default on startup, you must use a combination of Windows application programming interface (API) functions and GetObject to be certain to detect an instance of Microsoft Excel 7.0. The following is an excerpt from the GetObject Function Example in Microsoft Access for Windows 95 online Help:
' Test to see if there is a copy of Microsoft Excel already running. On Error Resume Next ' Defer error trapping. ' GetObject function called without the first argument returns a ' reference to an instance of the application. If the application ' is not running, an error occurs. Note the comma used as the first ' argument placeholder. Set MyXL = GetObject(, "Excel.Application")Notice that the comment states that Set MyXL = GetObject(, "Excel.Application") will detect whether there is an instance of Excel already open.
MORE INFORMATIONIn versions of Microsoft Excel prior to version 7.0, Excel was automatically registered in the ROT when it opened. Microsoft Excel 7.0 doesn't automatically register in the ROT by default on startup. The following sample code uses Windows API functions to detect if Microsoft Excel 7.0 is running and to register it in the ROT.
' Test to see if there is a copy of Microsoft Excel already running. On Error Resume Next ' Defer error trapping. ' GetObject function called without the first argument returns a ' reference to an instance of the application. If the application ' is not running, an error occurs. Note the comma used as the first ' argument placeholder. DetectExcel Set MyXL = GetObject(, "Excel.Application") REFERENCESFor more information about the GetObject function, search on the phrase "GetObject," and then view "GetObject Function" using the Answer Wizard from the Microsoft Access for Windows 95 Help menu. For more information about GetObject not detecting Microsoft Excel Version 7.0, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q138723 TITLE : Code to Access MS Excel Doesn't Work in Version 7.0 ARTICLE-ID: Q153029 TITLE : Microsoft Excel 95 Doesn't Respond Correctly to GetObject |
Additional query words: started open
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |