General information
Category:
ActiveX controls in VFP
Title:
VFP and EXCEL ActiveX Automation Problems
I have a batch process that builds about 50 spreadsheets every morning. VFP6 builds the Excel97 spreadsheets, and the first few always work fine. Somewhere along the way, the process crashes on me.
One of two events occur: either the createobject() command fails, (which a re-start of the machine easily fixes) or Excel hangs somewhere, leaving VFP to give an ugly retry message trying to communicate with the ActiveX Excel Session. The latter of the two usually requires a few Ctrl-Alt-Deletes to shut down and a reboot.
At first I thought that I was not shutting down the spreadsheet completely and freeing the memory properly.
I use the following code to shut down and release the object:
ExcelObj.Quit
RELEASE ExcelObj
I even use code from Microsoft's site to make sure the object is released:
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
And I still can not get 50 spreadsheet to run in a row.
Ten bucks go to the person who can help me solve this mystery.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only