kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Found this code here on the forum and need help with modification :
I want it to save without asking me to choose the file name. Then the file path should be in a folder called MyPdf in the ThisWorkbook. Path
Thanks in advance
Kelly
Code:
Private Sub CommandButton2_Click()
'This macro opens the SaveAs option with the defult file path "you have to set this file path below" coverts the whole sheet into .pdf file format
'And opens the .pdf to view <-- you can disable the view after covert option with lower code: OpenAfterPublish:=False
pdfName = ActiveSheet.Range("T1")
ChDir "C:\Temp\" 'This is where youo set a defult file path.
fileSaveName = Application.GetSaveAsFilename(pdfName, _
fileFilter:="PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
MsgBox "File Saved to" & " " & fileSaveName
End Sub
I want it to save without asking me to choose the file name. Then the file path should be in a folder called MyPdf in the ThisWorkbook. Path
Thanks in advance
Kelly