Hello all,
I am encountering the following error message when I try to generate a PDF from a checkbox list of multiple sheets.
"Run-time error '1004':
Document not saved. The document may be open, or an error may have been encountered when saving."
Any help would be appreciated with helping this problem. The last section of the code is what gets highlighted when I debug:
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\TestFolder\Book1.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
I am encountering the following error message when I try to generate a PDF from a checkbox list of multiple sheets.
"Run-time error '1004':
Document not saved. The document may be open, or an error may have been encountered when saving."
Any help would be appreciated with helping this problem. The last section of the code is what gets highlighted when I debug:
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\TestFolder\Book1.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Code:
Private Sub chbxEnter_Click()
Dim PDFsheets As String
Dim s As Worksheet
PDFsheets = "Approval Form,Business Plan,Deal Worksheet,All Manager Deal Recap,Deal Recap,MEC Dealership Profile,Loyal,Mid Loyal,Non Loyal,Projected Incentive Report,MEC"
ary = Split(PDFsheets, ",")
If CheckBox1.Value = True Then
PDFsheets = "Approval Form"
End If
If CheckBox2.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Business Plan"
Else
PDFsheets = PDFsheets & ",Business Plan"
End If
End If
If CheckBox3.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Deal Worksheet"
Else
PDFsheets = PDFsheets & ",Deal Worksheet"
End If
End If
If CheckBox4.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Deal Recap"
Else
PDFsheets = PDFsheets & ",Deal Recap"
End If
End If
If CheckBox5.Value = True Then
If PDFsheets = "" Then
PDFsheets = "All Manager Deal Recap"
Else
PDFsheets = PDFsheets & ",All Manager Deal Recap"
End If
End If
If CheckBox6.Value = True Then
If PDFsheets = "" Then
PDFsheets = "MEC Dealership Profile"
Else
PDFsheets = PDFsheets & ",MEC Dealership Profile"
End If
End If
If CheckBox7.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Loyal"
Else
PDFsheets = PDFsheets & ",Loyal"
End If
End If
If CheckBox8.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Mid Loyal"
Else
PDFsheets = PDFsheets & ",Mid Loyal"
End If
End If
If CheckBox9.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Non Loyal"
Else
PDFsheets = PDFsheets & ",Non Loyal"
End If
End If
If CheckBox10.Value = True Then
If PDFsheets = "" Then
PDFsheets = "Projected Incentive Report"
Else
PDFsheets = PDFsheets & ",Projected Incentive Report"
End If
End If
If CheckBox11.Value = True Then
If PDFsheets = "" Then
PDFsheets = "MEC"
Else
PDFsheets = PDFsheets & ",MEC"
End If
End If
Sheets(ary).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\TestFolder\Book1.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub