aworthey
06-07-2016, 08:13 AM
Hello,
I have code that saves a PDF of my spreadsheet to my desktop with custom print settings. It works perfectly except when I enable the PageSetup settings. When these settings are enabled within the code, my user-defined formula generates error messages within the cell.
What is it about the PageSetup settings that is interfering with my user-defined formula?
Here's the PDF print code:
Sub Button2()
Application.ScreenUpdating = False
Dim strFilename As String
Dim rngRange As Range
Dim konumber As String
konumber = Environ$("UserName")
Set rngRange = ThisWorkbook.Sheets("CostWorksheet").Range("D4")
strFilename = rngRange.Value & Format(Now(), "mmddyyyy hhmm")
ThisWorkbook.Sheets("CostWorksheet").Activate
'With ActiveSheet.PageSetup
'.Orientation = xlLandscape
'.Zoom = False
'.FitToPagesWide = 1
'.FitToPagesTall = 1
'End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\" & konumber & "\Desktop\" & strFilename & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
ActiveCell.Offset(1, 100).Activate
Application.ScreenUpdating = True
End Sub
Thanks!
I have code that saves a PDF of my spreadsheet to my desktop with custom print settings. It works perfectly except when I enable the PageSetup settings. When these settings are enabled within the code, my user-defined formula generates error messages within the cell.
What is it about the PageSetup settings that is interfering with my user-defined formula?
Here's the PDF print code:
Sub Button2()
Application.ScreenUpdating = False
Dim strFilename As String
Dim rngRange As Range
Dim konumber As String
konumber = Environ$("UserName")
Set rngRange = ThisWorkbook.Sheets("CostWorksheet").Range("D4")
strFilename = rngRange.Value & Format(Now(), "mmddyyyy hhmm")
ThisWorkbook.Sheets("CostWorksheet").Activate
'With ActiveSheet.PageSetup
'.Orientation = xlLandscape
'.Zoom = False
'.FitToPagesWide = 1
'.FitToPagesTall = 1
'End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\" & konumber & "\Desktop\" & strFilename & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
ActiveCell.Offset(1, 100).Activate
Application.ScreenUpdating = True
End Sub
Thanks!