0
我有一个Active X按钮,单击时会为我的工作簿中的每个工作表打开一个带有复选框的用户窗体。我想要做的是允许用户选择他们想要生成的PDF到PDF中。目前,无论用户点击生成PDF的输入按钮时选择的复选框是什么,工作簿中的所有工作表都包含在PDF中,而不是选定的内容,并且子工具不会自动结束,我必须自动进入VBA并点击停止按钮。所以,如果你能让我知道我在做什么我的代码出错了,为什么复选框没有选择我想要生成PDF的工作表。预先感谢所有帮助!复选框不选择用于PDF生成的工作表
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
ThisWorkbook.Sheets(ary).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
ActiveWindow.SelectedSheets(1).Select
End Sub