Print to PDF Single Page from Worksheet

walters303

New Member
Joined
Jan 28, 2015
Messages
2
Using Excel 2013. I have several different worksheets with varying number of pages. I'm looking to put a macro button on the different pages that I want to print-to-pdf so that all i need to do is click the button and THAT particular page prints.

When it prints-to-pdf I want the pdf page to automatically go to my desktop with the worksheet name and nothing else. The vba code that allows me to do this with in a completely different situation is below. Note: I dont want the date to be part of the filename. Thanks for the help!

Sub Save_ActSht_as_Pdf()
' Saves active sheet as PDF file.
Dim Name As String

Name = ThisWorkbook.Path & "\" & ActiveSheet.Name & " " & _
Format(Now(), "mm.dd.yy") & ".pdf"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
 

RatExcel

Board Regular
Joined
Aug 24, 2014
Messages
222
So you just want to remove date from file name and change it to save on Desktop?
 

Blade Hunter

Well-known Member
Joined
Mar 13, 2008
Messages
3,147
Perhaps this??
Rich (BB code):
Sub SaveCopy()
Dim ArchiveFolder as string, ArchiveFileName as string
ArchiveFolder = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\"
ArchiveFileName = ActiveSheet.Name
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=ArchiveFolder & ArchiveFileName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
 

walters303

New Member
Joined
Jan 28, 2015
Messages
2
So you just want to remove date from file name and change it to save on Desktop?
Correct. I want the title of the active page pdf to just be the worksheet name. No date. I just included that macro bc i have success with it. Thanks.
 

Blade Hunter

Well-known Member
Joined
Mar 13, 2008
Messages
3,147
Also don't use variable names like "Name" it is a reserved word and can give you issues :).

Cheers

Dan
 

Forum statistics

Threads
1,085,217
Messages
5,382,402
Members
401,787
Latest member
hDalal

Some videos you may like

This Week's Hot Topics

Top