Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
Before I convert my chart over to a PDF, I do a print preview to make sure everything is going to fit onto 8.5 inch x 11 inch paper and it looks like it will. That being said, I, when I run the code below, and when it gets to the "openafterpublish", it cuts off the bottom part of my chart. Is there a way to adjust the print area size with VBA code? Here's what I have so far. Thank you in advance.
VBA Code:
Private Sub cmdbtnPDF_Save_Click()
Dim sPath As String
Dim sFilename As String
Dim wbAnswer As Integer
sPath = "C:\Users\" & Environ("username") & "\Desktop\Save PDF Test\"
sFilename = Range("E2").Text & "_" & Format(Now, "mm.dd.yyyy") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFilename, IgnorePrintAreas:=True, openafterpublish:=True, IncludeDocProperties:=False
ActiveWorkbook.Save
wbAnswer = MsgBox("Are you sure you want to close this workbook and Excel?", vbYesNo + vbDefaultButton1 + vbQuestion, "WORKBOOK: " & ActiveWorkbook.Name)
If wbAnswer = vbYes Then
ActiveWorkbook.Save
Application.Quit
Else
Exit Sub
End If
End Sub