Good afternoon all,
Im wanting to make a macro that will save a single sheet as a pdf, and Ive done some research, but im more or less clueless.
Good afternoon all,
Im wanting to make a macro that will save a single sheet as a pdf, and Ive done some research, but im more or less clueless.
Last edited by Sky188; 06-06-2013 at 02:28 PM.
I managed to find the below code, and it works quite well.
Sub Save_as_pdf() Dim FSO As Object Dim s(1) As String Dim sNewFilePath As String Set FSO = CreateObject("Scripting.FileSystemObject") s(0) = ThisWorkbook.FullName If FSO.FileExists(s(0)) Then '//Change Excel Extension to PDF extension in FilePath s(1) = FSO.GetExtensionName(s(0)) If s(1) <> "" Then s(1) = "." & s(1) sNewFilePath = Replace(s(0), s(1), ".pdf") '//Export to PDF with new File Path ActiveSheet.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=sNewFilePath, _ Quality:=xlQualityStandard, IncludeDocProperties:=True, _ IgnorePrintAreas:=False, OpenAfterPublish:=True End If Else '//Error: file path not found MsgBox "Error: this workbook may be unsaved. Please save and try again." End If Set FSO = Nothing End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks