Article ID: 132535
Article Last Modified on 6/6/2003
"Insufficient Memory"
"Not enough memory"
"Page Fault"
PROCEDURE xlquit
local llFlag
ON ERROR llFlag = .F. && Exit loop
llFlag = .T.
DO WHILE llFlag
y=GETOBJECT (,"Excel.Application")
y.QUIT
ENDDO
ON ERROR && Set back to default
If you are using Microsoft Excel 7.0, use the following code:
PROCEDURE xlquit
DECLARE LONG FindWindowA IN USER32 AS FindA STRING,STRING
DECLARE LONG SendMessageA IN USER32 AS SendA LONG, LONG, LONG, LONG
WM_USER = 1024
hwnd = FindA("XLMAIN", 0)
DO WHILE hwnd > 0
WhatD= SendA(hwnd, WM_USER + 18, 0, 0)
y=GETOBJECT (,"Excel.Application")
y.QUIT
hwnd = FindA("XLMAIN", 0)
ENDDO
The code is different because Microsoft Excel 95 contains a bug that
was corrected in later versions.WhatD= SendA(hwnd, WM_USER + 18, 0, 0)to the following:
WhatD= SendA(hwnd, WM_ACTIVATEAPP, 0, 0)
153025 FIX: Microsoft Excel 95 Doesn't Respond Correctly toGetObject
FOR i = 1 to 5
x = CREATEOBJECT("Excel.Application")
RELEASE x
ENDFOR
Releasing the variable x does not terminate the instance of Microsoft
Excel. To ensure that each instance is terminated, add the following
command immediately before the RELEASE x command:
x.QuitTo test if an instance of Microsoft Excel exists use this function:
x=GETOBJECT(,"Excel.Application") && The first argument is emptyThis returns an OLE error if no instance of Microsoft Excel is in memory.
Additional query words: VFoxWin
Keywords: kbprb KB132535