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
Any and all suggestions are welcomed and much appreciated.
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.