UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Save Excel File As Pdf With Worksheet Name, Office 2013    
 
   
bakersburg9
post Jul 26 2019, 09:54 AM
Post#1



Posts: 5,562
Joined: 2-November 04
From: Downey, CA


I have this proc that saves an [bold]EXCEL[/bold] file with the worksheet name as part of the file name

CODE
MName = ActiveSheet.Name & ".xls"
MDir = ActiveWorkbook.Path
ActiveWorkbook.SaveAs Filename:=MDir & "\" & "Q2_Bonus_" & MName

... so if the tab is named "JohnSmith," the file name is "Q2_Bonus_JohnSmith" I also have code I used the macro recorder on that saves a file as .pdf:

CODE
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\SJR\Documents\Q2 2019 JohnSmith.pdf", Quality _
        :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=True


... I'm trying to combine the two, but I can't get the syntax right - I need to open an excel file, save it as a .pdf with the worksheet name as part of the .pdf file name, but i can't get it to work - also is there any unncessary parts of the code for the .pdf that is useless, that I can delete ?
Go to the top of the page
 
ADezii
post Jul 26 2019, 10:36 AM
Post#2



Posts: 2,641
Joined: 4-February 07
From: USA, Florida, Delray Beach


If I understand you correctly, this should do the trick:
CODE
Dim strPath As String

strPath = ActiveWorkbook.Path & "\" & "Q2_Bonus_" & ActiveSheet.Name & ".pdf"

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

This post has been edited by ADezii: Jul 26 2019, 10:36 AM
Go to the top of the page
 
bakersburg9
post Jul 29 2019, 01:29 PM
Post#3



Posts: 5,562
Joined: 2-November 04
From: Downey, CA


Thanks, Adezii ! cool.gif

Steve
Go to the top of the page
 
ADezii
post Jul 29 2019, 05:17 PM
Post#4



Posts: 2,641
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif ,Good Luck with your Project.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th September 2019 - 09:41 PM