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: 

How do you save an Excel file as a PDF?

Solved!
Go to solution

That's good news.  I'm glad I was able to help you figure it out.

 

It is always fun when you can figure out the tricks to combine the power of LabVIEW programming with the power of ActiveX programming to be able to get some sophisticated programming tasks working.

0 Kudos
Message 11 of 19
(2,181 Views)

Dear all,

 

You can use the workbook Invoke method: ExportAsFixedFormat, and as the type of the file select "xlTypePDF" as you can see in the .png attached..

 

Enjoy,

 

Yogev.

Message 12 of 19
(2,141 Views)

Hi,

 

Is there any way to save specific worksheet in separate PDF ? now its working and entire excel file will save in one PDF but I need to save different different worksheet in separate PDF.

 

can you please help.

 

Regards,

Vinay

0 Kudos
Message 13 of 19
(1,538 Views)

Hi Vinay,

 


@Vinaygowda wrote:

Is there any way to save specific worksheet in separate PDF ? now its working and entire excel file will save in one PDF but I need to save different different worksheet in separate PDF.


So you already know how to print "entire" Excel files into PDFs!?

Then your problem reduces to move the worksheets you want to print into their own Excel workbook. In Excel this is usually done by right-clicking the worksheet tab and "copy/move" the worksheet…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 19
(1,526 Views)

What happens if you execute the ExportAsFixedFormat() method of a worksheet, rather than the workbook? 

Rolf Kalbermatter
My Blog
0 Kudos
Message 15 of 19
(1,520 Views)

Rolfk,

 

To answer your question, I don't know as I have never tried it (and not the OP).

 

For things like this, I just use the Record Macro feature, do what I want, and then port the generated VBA code over to LabVIEW ActiveX, with some light massaging. From the Developer - Code - Record Macro ribbon (Excel 365), I get this in a Module window:

 

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Your_File_Path\Your_PDF_File.pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

 

Just plug those in a ActiveX Method/Property (some might be the defaults so the OP should reference the MSDN site) and it should work.

0 Kudos
Message 16 of 19
(1,496 Views)

Hello GredW,

 

Thanks for your replay,

 

I found solution to my problem where we exporting excel file as PDF format. And if we want to get specific worksheet of excel file we need to mention which sheet we need in PDF. so for trail i converted excel to PDF and I chosen particular sheet in PDF by wiring sheet numbers as shown in picture below. 

Vinaygowda_0-1594347250548.png

so I get the particular sheet in PDF 

 

Thank you,

Vinay

 

0 Kudos
Message 17 of 19
(1,466 Views)

Glad you found a solution.

 

One suggestion, I see you have the 6th page selected and hard coded. You might want to dynamically find that page and pass that parameter in to that function assuming it moves.

0 Kudos
Message 18 of 19
(1,449 Views)

Not bad but the Worksheet refnum should also support this method. The "ActiveSheet" reference in the recorded Visual Basic macro that RavensFan and later Eric posted definitely references a worksheet object and not the entire workbook object.

 

So if you have the reference to the worksheet in question you should be able to directly export that without the need to export fixed page offsets from the entire workbook.

Rolf Kalbermatter
My Blog
0 Kudos
Message 19 of 19
(1,444 Views)