From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

automation refnum MSWord close

Solved!
Go to solution
My program interacts with MSWord for it's report generation. MSWORD is minimized, but if someone closes MSWORD, the LV Automation Refnum isn't valid anymore. I was thinking of looking for a valid handle (>0 perhaps) and if it isn't valid then opent the application again and keep going. How should i handle it?
0 Kudos
Message 1 of 3
(2,560 Views)

Hmm.  I've mainly used the RGT with Excel, and if I open Excel minimized, Excel exists only on the Taskbar (making it "unlikely" that the user will close it before I'm done).  Doesn't starting Word minimized do the same thing?  

 

If I were thinking about using this for logging, and was updating infrequently (say, every 5 minutes), and wanted "extra safety", what I might consider is to open the file, do my writes, close it, and repeat five minutes later.  [In my current situation, where I'm using Excel to control a behavioral study that can last an hour, with new trials every 20-30 seconds, I open Excel, leave it open, but my users know to "only look, don't touch" while the program runs ...

 

Bob Schor

0 Kudos
Message 2 of 3
(2,536 Views)
Solution
Accepted by topic author Regulator
Checking Documents.Count results in error. When MSWORD is closed the Application Refnum was killed as well. The .NET REFNUM is still valid, so opening another automation reference using Automation Open inside the error trap along with Application.Documents.Open I was able to get it to open persistently.
0 Kudos
Message 3 of 3
(2,529 Views)