Export Excel Sheet to PDF available for printing

littlejilly

Board Regular
Joined
Sep 8, 2011
Messages
168
Hello All,

I have written a Macro code that prints a worksheet to a pdf file. How can I edit the code so that it automatically opens the pdf without asking to save it first or just automatically saves it as "Summary" to the desktop. Also, would it possible when open the pdf to print the excel worksheet to a landscape or portrait view? I would also like to scale down the view so that it only spans the width of one pdf landscape page.

I have included the code that currents prints to pdf below

Code:
Private Sub PrintToPDF_Click()

Dim fileName As String

Sheets("Summary").Select
'set the path and file name
fileName = "C:WINDOWSDesktopsheet1.PDF"
'Enters the name and path of the PDF file when the PrintFileAs dialog box is opened
SendKeys fileName & "{ENTER}", False
'prints the file
Worksheets("Summary").PrintOut ActivePrinter = "Adobe PDF on Ne04:"

End sub

Any and all suggestions are welcomed and much appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,203,453
Messages
6,055,530
Members
444,794
Latest member
HSAL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top