LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I print a Word document using ActiveX

Solved!
Go to solution

The example code they list on the first website I pointed you too looks like this: .ActiveDocument.PrintOut(0,0,"3","","4","8")

 

I'm wondering if windows needs a blank string varaible to be written to the outputfile name property in order for everything to function properly. 

 

From the prototype it looks like for range set to 3 you'll need integers for the background and append properties. Then strings for range, outputfile name (blank string), from, and to.

 

It appears you can leave the rest of the properties blank. Try setting it up that way and see what happens.  

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 11 of 31
(1,810 Views)

Hi Zach,

 

By "blank string" do you mean an empty string contstant?

 

I've tried all that to no avail.

 

I have attached my file once more.

 

Regards,

Chris

 

 

 

0 Kudos
Message 12 of 31
(1,807 Views)

I'm able to get it working in word 2007 when I have it set up like below. 

 

try this.png

Applications Engineer
National Instruments
CLD Certified
Message 13 of 31
(1,802 Views)

Now with the empty char constant on the OutPutFileName, it wants to save to a .prn file.

I disconnected the empty char constant.

I am unable to shut off the print to file.

 

I have closed the program without saving and reopened it. No change.

I closed and reopened LabView 2010. No change.

Previously it was printing to my default network printer.

???

 

Thanks,

Chris

 

0 Kudos
Message 14 of 31
(1,797 Views)

Got it going to the printer once again. I entered quotes  ""  into the char constant.

 

The rest of the problems persist.

0 Can only print all pages.

1 prints a blank page

2,3,4, print nothing, however something (looks like zero pages) is sent to the printer per a network reply.

 

Chris

0 Kudos
Message 15 of 31
(1,794 Views)

Zach,

 

Are you using LV2010 or LV2011?

I only have LV2010 loaded on my machine. I have not yet installed 2011.

Maybe I need to use 2011?

 

Can you try the .vi in V2010?

 

Thanks,

Chris

 

0 Kudos
Message 16 of 31
(1,789 Views)

Even when you wire it exactly as I did? (except with your added quotations) In the VI you sent me you had pages and to from wired in. It may not accept that, try just having one or the other.

 

It makes sense that two doesn't do anything. You don't have a current page up in word.

 

Also try watching the VI with highlight execution on. It will throw an error if you don't have the properties configured correctly.  

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 17 of 31
(1,788 Views)

I was originally using 2011 SP1, but I can verify that it works on 2010 as well. I am using word 2007 though not 2010.  

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 18 of 31
(1,787 Views)

It certainly does throw an error if one if the inputs is in the wrong format. Seen that many times.

So I'm guessing you don't have Word 2010 available?

Let me know about LV2010 operation.

 

Thanks,

Chris

 

I may go ahead and install 2011 and try again.

However, as I recall, installing 2011 blew out something and I had to uninstall 2011, 2010 and reinstall 2010. Not so good.I may not want to try this.

0 Kudos
Message 19 of 31
(1,781 Views)

No I don't have ready access to it, we're currently running on MS Office 2007. As I said previously, this VI works in 2010. 

 

The problem is likely related to the format of the ActiveX call not LabVIEW. That's further reinforced by the fact that you're continually throwing errors.   

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 20 of 31
(1,774 Views)