LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft Word, check if document is opened!

Hi I'm trying to create a SubVI which checks if a word application or document is opened!
I've already done this in excel and it works fine, but Word seems to be a bit different (atleast acording to me).
I'm using activex objects and maybe this is not the ideal way of doing it, but its a way.
My real problem using word is that it seems to be really sensitive about open references and doesnt work properly  if references aren't closed.
The excel example works fine and when I try to do the same in Word I can't close the ref. because I get an error. I've done another program that goes around this problem, and doesnt seem to open any references, but I still get an error which doesn't look very nice.
 
Can someone explain what global ref is and why I get this error?
 
Regards Andreas
 
 
There's three different kinds of people, those who can count, and those who can't.
Download All
0 Kudos
Message 1 of 5
(3,461 Views)
Not clear what you're doing based on what you're saying. You're not closing any reference in your code. Both of your VIs ran without error. The one for Word indicated a true even though I didn't have Word running, but that's because I had Outlook running, which uses Word as the mail message editor. You had what seems to be an odd comment on the front panel of "Run cont.". Are you trying to run this continuously.

Side comment: I noticed you doing this in your other VI that you posted regarding error code and control references. You're labeling controls as "local variables", and placing them in a special section of your front panel with big decoration that says "Local variables". Controls are not local variables. As in your previous VI concerning control references, you do not need to create a control to wire to the "Automation Open" function. You can use a block diagram constant. That would eliminate the need to do what you're doing with the "Local Variables" misplaced terminology.
0 Kudos
Message 2 of 5
(3,439 Views)
Hi
I know I don't get an error running the excel VI, but when I run the word VI I get:
-2147221164. Class not registered in Word Check if Open.vi ??? That's my question, why do I get this error, and what is a global reference?
 
Regarding the local variables comment!
I was a bit confused myself, a local variable is something else in my ears, but this is the way I've been told to do it so I'm basicly following orders.  
There's three different kinds of people, those who can count, and those who can't.
0 Kudos
Message 3 of 5
(3,417 Views)
Well, like I said, when I ran your "Word Check if Open" VI, I did not get an error, so the problem, as far as I can tell, isn't with the VI, but with the computer you're running it on. One thing I noticed is that when I opened the VI it showed as having been changed. The change was that an external interface was changed, meaning that it had to resync with the version of Word that I had installed on my computer, which is probable different than the one you have. The "Class not registered" is a pretty generic error, and is usually pretty hard to track down. A few things to try:
  • If you're not logged in as Administrator, log in as Administrator and see if that makes a difference. Could be a permissions problem.
  • Take a look at the document "How Do I Manually Register Type Libraries, ActiveX Controls, and ActiveX Servers?". Word is an ActiveX Server.
  • See if the same thing happens on another computer, or better yet, on another computer running a different version of Word.
  • See if the same thing happens when you try to instantiate the ActiveX interface using something like VB.
Sorry I couldn't be of much help on this one.

Regarding your question on global reference: that term is pretty meaningless without a context. Usually it's a reference that you keep in a global variable that you access within an application. Or, are you referring to the "Global" object that you're using in the VI? In that case, the "Global" object is just a shortcut. From the Office Visual Basic Reference:


Global Object

Contains top-level properties and methods that don't need to be preceded by the Application property. For example, the following two statements have the same result.

Documents(1).Content.Bold = True
Application.Documents(1).Content.Bold = True

0 Kudos
Message 4 of 5
(3,398 Views)
Thanx for all your help. I'll try them out and see whats wrong.
 
Reagards/ Andreas
There's three different kinds of people, those who can count, and those who can't.
0 Kudos
Message 5 of 5
(3,388 Views)