BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Rhodochrosite | Level 12

Hi Everyone,

I have an invoice in Excel sheet with graphic and table.

I wonder if SAS can help to print that Excel page into PDF.

The outcome is just like we use Save As PDF in Excel.

Thanks,

HHC

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
I would recommend using ODS PDF if you can...if you cannot, use VBS.

https://gist.github.com/statgeek/c51f58a009f8d315a200f34912e494b1

Change this line
mybook.SaveAs ""&default.\"" & Filename & "".xlsx"", 51";

to

mybook.SaveAs ""&default.\"" & Filename & "".pdf"", 51";

You'll need to figure out what that 51 should be - I can't seem to find it easily but it's out there somewhere.
It's not listed here which is where I'd usually find it, but I'm fairly certain I've done this before. https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Why use SAS here? Excel can save as PDF.

--
Paige Miller
Reeza
Super User
I would recommend using ODS PDF if you can...if you cannot, use VBS.

https://gist.github.com/statgeek/c51f58a009f8d315a200f34912e494b1

Change this line
mybook.SaveAs ""&default.\"" & Filename & "".xlsx"", 51";

to

mybook.SaveAs ""&default.\"" & Filename & "".pdf"", 51";

You'll need to figure out what that 51 should be - I can't seem to find it easily but it's out there somewhere.
It's not listed here which is where I'd usually find it, but I'm fairly certain I've done this before. https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1843 views
  • 1 like
  • 3 in conversation