Sub ExportWorkbookAsPDF()
Dim wb As Workbook
Dim ws As Worksheet
Dim filePath As String
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
filePath = Environ("USERPROFILE") & "\Desktop\" & Left(wb.Name, InStrRev(wb.Name, ".")) & ".pdf"
ws.Columns("A").ColumnWidth = 4.78
ws.Columns("B").ColumnWidth = 13.11
ws.Columns("E").ColumnWidth = 13.11
ws.Columns("F").ColumnWidth = 9.11
ws.Columns("G:H").ColumnWidth = 10.33
ws.Columns("C:D").ColumnWidth = 13
ws.Columns("I").ColumnWidth = 10.56
ws.Columns("O").ColumnWidth = 9.22
ws.Columns("P").ColumnWidth = 10.56
ws.Columns("R").ColumnWidth = 10.33
ws.Columns("S").ColumnWidth = 9.22
ws.Columns("U").ColumnWidth = 9.22
wb.ActiveSheet.PageSetup.Orientation = xlLandscape
Dim tableRange As Range
Set tableRange = ActiveSheet.Range("A1:V13")
ActiveSheet.Rows(tableRange.Row + tableRange.Rows.Count & ":" & ActiveSheet.Rows.Count).Hidden = True
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
Here’s my code, it’s quite simple but basically it keeps showing error in this active workbook export. Idea is to transform the file to fit landscape view as pdf and save it to desktop. I know there’s a function to automatically save it to fit, but the issue is it doesn’t save the file to desktop as pdf
Dim wb As Workbook
Dim ws As Worksheet
Dim filePath As String
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
filePath = Environ("USERPROFILE") & "\Desktop\" & Left(wb.Name, InStrRev(wb.Name, ".")) & ".pdf"
ws.Columns("A").ColumnWidth = 4.78
ws.Columns("B").ColumnWidth = 13.11
ws.Columns("E").ColumnWidth = 13.11
ws.Columns("F").ColumnWidth = 9.11
ws.Columns("G:H").ColumnWidth = 10.33
ws.Columns("C:D").ColumnWidth = 13
ws.Columns("I").ColumnWidth = 10.56
ws.Columns("O").ColumnWidth = 9.22
ws.Columns("P").ColumnWidth = 10.56
ws.Columns("R").ColumnWidth = 10.33
ws.Columns("S").ColumnWidth = 9.22
ws.Columns("U").ColumnWidth = 9.22
wb.ActiveSheet.PageSetup.Orientation = xlLandscape
Dim tableRange As Range
Set tableRange = ActiveSheet.Range("A1:V13")
ActiveSheet.Rows(tableRange.Row + tableRange.Rows.Count & ":" & ActiveSheet.Rows.Count).Hidden = True
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
Here’s my code, it’s quite simple but basically it keeps showing error in this active workbook export. Idea is to transform the file to fit landscape view as pdf and save it to desktop. I know there’s a function to automatically save it to fit, but the issue is it doesn’t save the file to desktop as pdf