SAS Programming

DATA Step, Macro, Functions and more
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

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 1759 views
  • 1 like
  • 3 in conversation