LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

print excel files

Is there a way to print out a specific excel file from a directory that has several excel files? Also, is there a way to combine the content of multiple of excel files into one single file and print out that file? I am using Report Generation Toolkit to save data to time/date stamped Excel files (using Excel Specific VIs). I am using LV 7, Win XP.

Thank you in advance.
0 Kudos
Message 1 of 6
(3,596 Views)
I do not have the report generation toolkit but I can tell you how to do it from scratch using active X commands. Also there is example programs to get you started.

1 open up excel and record a macro of everything you want to do.
2. Duplicate the macro using Active X nodes.

See examples and search the web for active X with excel
here are some examples



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 2 of 6
(3,596 Views)
Hi jhoskins,

THanks for the response. I am not very familiar with active X. That's one of the reasons I bought the RG Toolkit so that I dont have to mess with active X. What I have done so far with the RG toolkit is create a excel file with 3 different worksheets. Then I save the excel file every hour with a different name. What I am looking for a method whereby a standard file dialog box pops up when I hit a "print" button so that the user can select the excel file he/she wants to print. In addition, I was wondering if there was a way to concatenate the content of multiple excel files and print out a comprehensive report at, say, end of the day.

Any help is appreciated.

thanks in advance.
0 Kudos
Message 3 of 6
(3,596 Views)
Create a string constant, and type the following in it.

Sub Excel_Print()
'print the whole workbook
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
End Sub

Using RG, use "Excel Import Module", "Run Macro" and "Remove Module" to execute this macro. Make sure you do not wire the error input for "Remove Module.vi". The module must be removed regardless error or not.

for single sheet (make sure the sheet is selected using "Get Worksheet.vi" from RG):

Sub Excel_Print()
'single sheet
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
End Sub

IMPORTANT: In order for this work, in EXCEL, you need go to "Tools >> Macro >> Security", lower the security settings on both tabs.

-Joe
0 Kudos
Message 4 of 6
(3,596 Views)
Does this allow me to open up a file dialog box to select which excel file i want to print? My report generation is a separate subvi that is called in the Main Program. So I need to hit a print button to bring up the windows dialog box that allows the user to select the specific excel file for printing.

Thanks
0 Kudos
Message 5 of 6
(3,596 Views)
You need guide the user to choose file, this operation just print the current open Excel file.

-Joe
0 Kudos
Message 6 of 6
(3,596 Views)