here is code that will save your pdf into C:\Temp and name it based on what is in A1
Sub SaveAsPDf()
Dim strFileName As String
Const strPath As String = "\Temp\"
strFileName = Range("A1")
ChDrive "C:\"
ChDir strPath
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
of course change as required
ps you dont need to have that CHDRIVE/CHDIR in there if you dont want
you can just add it directly into the file name...like so
Sub SaveAsPDf()
Dim strFileName As String
strFileName = Range("A1")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\temp\" & strFileName, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
in fact you can shorten it even more to
Sub SaveAsPDf()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\temp\" & Range("A1"), IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
Bookmarks