- Jim Reese
- PowerBuilder
- Thursday, 25 July 2024 08:12 PM UTC
We have existing processes to export something to excel using OLE and Excel VBA commands, which do their job, and then exit. We have a call at the end to an external function EndTask to kill the excel.exe process for these.
We're developing a new process that is more interactive, exporting data from a data-entry datawindow with multiple detail rows, allowing the user to manipulate the data in the excel spreadsheet that was created during the download, and then re-importing the data and simulating manual entry using setrow/setcolumn/settext/accepttext in order to use pre-existing validation code. Development is actually proceeding nicely, with good performance.
One issue we're facing is we want the user to be able to open other workbooks from our newly created workbook/worksheet, in order to copy/paste data if they desire. as well as allow them to keep these open if desired after the upload process has completed.
If we omit the existing external function to kill the excel.exe process like the earlier processes do, then even after the user has closed all existing workbooks, and we have disconnected in PB, there is an orphan excel.exe process in the task manager. We've tested the following simple process, and the orphan still remains:
oleobject lole_excel
lole_excel = create oleobject
lole_excel.ConnectToNewObject("Excel.Application")
lole_excel.visible = TRUE
lole_excel.disconnectobject( )
destroy lole_excel
return
With the .visible set to true, an empty Excel frame with no sheet is displayed. Closing it does not terminate the excel.exe process.
Without the .visible set to true, the user sees nothing, but the orphan excel.exe process remains. Executing multiple times creates a new excel.exe process each time.
We were hoping that once all references to the process went away, then the process would close down, similar to how Excel does when initiated manually, but it seems since it is started via OLE, the only way to terminate is with the external EndTask function:
Function boolean EndTask(ulong hWnd, boolean fShutDown, boolean fForce) Library "user32.dll"
Calling EndTask will close all open Excel windows opened from the OLE instance when it executes, which is what we are trying to avoid.
Any suggestions?
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.