08-02-2010 03:30 PM
Hello,
I have developed a VI (based on ActiveX) that writes to a spreadsheet with some formatting. Past posts on this forum were very helpful in getting me at this point and Kudos to members who have posted VIs, LLBs, and created a thread just for Excel automation.
I've one question related to Excel application closing:
Currently, I am doing a clean close of all references in my VI for report generation using ActiveX. If I am viewing any open workbooks in excel when my VI is running then it closes all open xls/xlsx files when the "Excel Automation Close" is executed.
My question is: Is it possible to somehow not close instance of Excel application that was not created/opened through LabVIEW?
Thanks.
08-02-2010 05:18 PM
What you would need to do is to check to see if there's an existing Excel process already running before you "do your thing". If there is, then you will want to just close the workbook rather than closing Excel, which terminates the Excel process.
How do you check to see if Excel is already running? You can just use tasklist via System Exec and parse the output. Other solutions have been suggested in the past, so if you search you can find them.
08-02-2010 05:59 PM
Thanks, smercurio_fc. I will try out the System Exec option.
08-03-2010 08:30 PM
Hello,
Using the System Exec VI, I am able to get the Process ID of Excel application instance. However, to use the workbook node, Application refnum is required.
Is there a way to get to the Application refnum using the process ID?
For now, I have figured out a way to avoid any Excel workbook closing with Automation close. Wiring True to Open New Instance in Open Automation seems to do the trick.
Thanks.
08-04-2010 10:10 AM
There is no way to convert the process ID to an automation refnum since there is no connection between the two. The only objective of that was to see if Excel was already running so you didn't try to close it.