LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

print dialog

Hi I need to print text files and csv files from labview and I would like to pop up a print dialog box, preferrably a standard windows one that show the the printers available, paper source, etc.
 
1. I have tried various approaches to this but none have been successful so far such as using an active x palette and inserting a Microsoft Common Dialog Control 6.0 v1.2 Type Library
 
This Results in an error code as i try to insert the Microsoft Common Dialog Control 6.0 : "Error inserting Active X or .NET object:: Class is not licensed for use"
 
2. Then I tried  placing an Automation Open VI on the block diagram,  right clicking the Automation Refnum input and selecting Create >> Constant.  Then right clicking the constant and select Select ActiveX Class >> Browse. Browsing to the Microsoft Common Dialog Control 6.0 v1.2 Type Library and select the object MSComDlg.ICommonDialog. But again this gave me a similar error as before "Class is not licensed for use"
 
 
But this would not open with LAbview 8.5 stating that "Labview: Vi version is too early to convert to the current LabView Version.  An error ocurred laoding VI 'PrintDialog.vi' Labview load error code 10:Vi version (5.0) is too old to convert to the current LabVIEW version (8.5)
 
I am kinda running out of options here, is it really that difficult to open a print dialog box.  Again i need to print out text files in my vi not the actual vi so Labview print dialog is kinda uselss to me
 
any help?
 
thanks
 
Reza
 
 
0 Kudos
Message 1 of 9
(4,569 Views)
I posted a LV 7.1 version of the VI in your original thread which you can import to 8.5.

This looks to be the Printer Setup dialog box, which may not be what you want.
0 Kudos
Message 2 of 9
(4,566 Views)
 
 I was hoping to choose the printer with the Print Dialog and then use the FileMan Print File.vi to print the file but i can't connect the 2 since the Print Daiilog has no inputs or outputs to connect to the okay and cancel buttons.
 
Any suggestions...should i caryy on this route or is ther a better method?
 
0 Kudos
Message 3 of 9
(4,561 Views)
Actually my bad, i noticed the success button on the printdialog1 and i used that as the output and it works fine....however now i can't get the right printer...i chose one with the printdialog but the fileMan Print file.vi chooses its own.....trying to find a way around it
0 Kudos
Message 4 of 9
(4,554 Views)
Unfortunatly i have been unable to combine them (fileMan Print file.vi and printdialog1.vi) together so if anybody knows of a simpler way of opening an standard window print dialog box and then printing a file (txt or csv if the extension matters)from Labview, it would be of great help. 
 
Thanks
0 Kudos
Message 5 of 9
(4,545 Views)

Hi reza_sed,

You might try changing the default printer and then using FileMan Print File.vi.  Here is a link to another discussion forum that mentions one way to change the default printer.  Be very careful using this VI though, because it edits the Windows registry which can be dangerous.

Regards,

James R.
National Instruments
0 Kudos
Message 6 of 9
(4,509 Views)

Hi James

Thanks for the reply, but it is not the printing or choosing the default printer that is the problem.   I am creating an application that will be used by customers and I wanted it to have a print capability where the user can press the print button and have the print dialog box pop up.  From there the user can then select the printer, the paper size and then print.  Now i can open the dialog box with the print dialog.zip but that only has one output and that is whether or not to print,  and the FileMan Print File.vi only prints to a default printer.  I don't want to exactly change the default printer since that might not be what the user wants to do plus the fact that it edits the windows registry is not to desirable for an application.   I have looked through these forums quite a bit and i still haven't been able to find what i want, which I believe isn't that demanding or weird, its just a standard print dialog box that allows you to choose a printer and print.  Almost every application has is, even Labview (Print Window...)!

Thanks

Reza

0 Kudos
Message 7 of 9
(4,490 Views)

Hi Reza,

My thought with changing the default printer was that it could be changed back automatically after the print job was sent.  Just an idea.  As far as getting the standard print dialog, if you look at the C code of how it was done in the PrintDialog VI, you can see that the PrintDlg function is called toward the bottom.  There is more information on how to use these Microsoft functions on the MSDN website located here:

Using Common Dialog Boxes

It might require a bit of work to get the standard print dialog box to show up, and then from there to print the document.

Regards,

James R.
National Instruments
0 Kudos
Message 8 of 9
(4,467 Views)
The problem that you have is that fileman print is opening notepad to print the document.  So, when you run the print dialog in LabVIEW, you're changing the settings in LabVIEW, unless you change the default printer.  I can find no information about getting notepad to print with a dialog box from the command line (which is what fileman print does).  You may have to open notepad (use system exec and run "notepad.exe your filename") on your own and use SendKeys() to open the print dialog (send CTRL-P), then use it again to close Notepad after printing is done (send ALT-F then send x).

An alternative would be to locate a text editor which always shows the dialog whenever you print.  Notepad shows the print dialog except when told to print via the command line.  Same for Wordpad.
0 Kudos
Message 9 of 9
(4,461 Views)