06-03-2026 07:21 AM
Hello,
I am using the Active IWebBrowser2 object to open a PDF file. The file loads successfully and displays without any issues.
Later in my application, I need to delete the PDF file. To release the file, I tried calling the Stop method on the IWebBrowser2 object, assuming it would close the file reference. However, when I attempt to delete the file afterward, I receive the following error:
LabVIEW: (Hex 0x5) File already open
This suggests that the PDF file is still being held open by the browser control or an associated process.
Can someone advise on the correct method or procedure to fully release the PDF file and close any file handles associated with it? Is there a specific method other than Stop that should be used before deleting the file?
06-03-2026 01:23 PM - edited 06-03-2026 01:24 PM
The IWebBrowswer object is never closed. Since it is ActiveX, this means the object remains in memory and will keep any documents it opened active too.
Possible solutions:
1) Close the IWebBrowser reference (and any other ActiveX reference you open or get from methods and property nodes you call on it or one of its subobjects).
2) Load a different document into the IWebBroser.