05-19-2012 01:14 AM
Hello!
Attached is a simple VI that uses the IWebBrowser2 (ActiveX) control to display an xls file.
The problem is that I need to access the IWebBrowser.Document property, but that causes Excel to stay open.
Run the VI with boolean=False and Excel will appear in the task manager for about 2 seconds.
Run the VI with boolean=True and Excel stays open indefinately (that is, until LabVIEW is closed).
Please help me figure-out how to get Excel to close!
Thanks in advance.
05-19-2012 07:53 AM
I can't verify this, but my guess is that there's an implied reference to Excel that's left open. You could try explicitly closing the reference to the Excel app after closing the reference to the workbook.
05-19-2012 08:42 AM
@550nm wrote:
Hello!
Attached is a simple VI that uses the IWebBrowser2 (ActiveX) control to display an xls file.
The problem is that I need to access the IWebBrowser.Document property, but that causes Excel to stay open.
Run the VI with boolean=False and Excel will appear in the task manager for about 2 seconds.
Run the VI with boolean=True and Excel stays open indefinately (that is, until LabVIEW is closed).
Please help me figure-out how to get Excel to close!
Thanks in advance.
When posting VIs don't assume everyone has LV2011.
When I can't open a VI, it is hard to tell what is "wrong".
05-19-2012 09:06 AM
Hi Smercurio,
The attached code explicitly Quits Excel and closes reference yet Excel stays open!. I believe you're on the right track, though, While investigating this on VB/Net forums someone recommends the .Net method "System.Runtime.InteropServices.Marshal.Release(Object)" to cleanup after accessing the Document object. I just don't see "Marshal" (or "Finish") exposed in the LabVIEWs System.Runtime.InteropServices - any ideas here?
NOTE: Attached also fixes a bug - forgot to wire Set Occurrance in callback VI.
Thanks in advance!
05-19-2012 09:10 AM
...sorry nyc, thanks for the reminder.
Am attaching code in 9.0 - please let me know if it's broken.
Thanks!
05-19-2012 09:19 AM
When I run your VI, the Excel workbook opens in Excel, it doesn't open in the web browser window.
I am running LV 2010 SP1 32-bit on Windows 7 64-bit.
And I have Excel 2010.
05-19-2012 10:04 AM
I fixed my problem. There is a problem with opening Office 2010 documents in IE7 and IE8. For anyone interested, the solution is at http://support.microsoft.com/kb/982995
Anyone, I am not sure what you are trying to achieve with this VI.
05-19-2012 10:06 AM - edited 05-19-2012 10:13 AM
Hi nyc,
The previously attached code has been cut out of a larger application. It's only purpose is to reproduce the problem of not being able to close Excel.
Cheers!
05-19-2012 10:22 AM - edited 05-19-2012 10:24 AM
Excel closes for me whether the Excel Open/Close is either true or false. There is not a residual Excel application running in Task Manager.
There are other ways to obtain the document properties of Office properties without going through all this gyration, but without knowing what you are trying to achieve it is hard to continue.
Good luck!
05-19-2012 12:34 PM
Hi nyc,
@nyc_(is_out_of_here) wrote:
Excel closes for me whether the Excel Open/Close is either true or false. There is not a residual Excel application running in Task Manager.
There are other ways to obtain the document properties of Office properties without going through all this gyration, but without knowing what you are trying to achieve it is hard to continue.
Good luck!
The problem comes when trying to use one of those "other ways" to update the sheet while IE is running a second instance of Excel which is also showing the sheet.
Try it.
It's curious that the problem doesn't happen for you - can you change your copy to NOT close the ActiveX Workbook ref? That should force Excel to stay open.
NI may have changed resource cleanup between 2010 and 2011, keeping the VI running might prevent Excel from closing - for TRUE case - on your platform.
Cheers!