PRB: Microsoft Excel Not Registered in Running Object TableLast reviewed: February 28, 1996Article ID: Q147573 |
The information in this article applies to:
SYMPTOMSAccording to Visual FoxPro Help, the following command will create a reference to a running instance of Microsoft Excel:
oleApp = GETOBJECT(,"Excel.Application")However, with Microsoft Excel version 7.0, this command can cause the following error even if Microsoft Excel is running:
OLE error code 0x800401e3: Operation unavailable CAUSEPrevious versions of Microsoft Excel register the application object in the OLE RunningObjectTable (ROT) on startup. This would happen under all circumstances, whether Microsoft Excel was Launched using OLE or not. Microsoft Excel 7.0 does not register the application object in the ROT on startup by default. However, Microsoft Excel 7.0 registers itself in the ROT in any of the following situations:
RESOLUTIONIn Visual FoxPro, send a WM_USER+18 message to the Main window of Microsoft Excel to force Microsoft Excel to register itself in the ROT.
STATUSThis behavior is by design.
MORE INFORMATIONThe following code demonstrates how to create a reference to a running instance of Microsoft Excel 7.0:
* Start sample code
* Main program code
oleExcel = findxl()
IF TYPE("oleExcel") = "N"
=MessageBox("No instances of Excel running !")
ELSE
oleExcel.WindowState = -4137 &&maximize Excel
ENDIF
FUNCTION findxl
DECLARE LONG FindWindowA IN USER32 AS FindA STRING,STRING
DECLARE LONG SendMessageA IN USER32 AS SendA LONG, LONG, LONG, LONG
WM_USER = 1024
PRIVATE myExcelApp
PRIVATE mySendMessage
hwnd = FindA("XLMAIN", 0)
IF hwnd = 0 then
RETURN 0
ELSE
mySendMessage = SendA(hwnd, WM_USER + 18, 0, 0)
myExcelApp = GetObject(, "Excel.Application")
RETURN myExcelApp
ENDIF
For more information about using the function GETOBJECT() to reference
Microsoft Excel, please see the following articles in the Microsoft
Knowledge Base:
ARTICLE-ID: Q132535 TITLE : Releasing Object Variable Does Not Close Microsoft Excel ARTICLE-ID: Q128994 TITLE : Behavior of GETOBJECT()With Excel and Word For Windows |
Additional reference words: 3.00 3.00b VFoxWin kbinf CREATEOBJECT OLE
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |