请参阅以下代码:
Sub SmartPDF_Generator()
Dim answer As Integer
pdfName = ActiveSheet.Cells(1, 5) & " __ " & Cells(1, 8)
answer = MsgBox("Please confirm creat dashboard for Carrier" & Cells(1, 5) & " Event" & Cells(1, 8), vbYesNo + vbQuestion, "Comfirm dashboard")
If answer = vbNo Then
MsgBox ("Please select your carrier and event combination again")
Else
ChDir ("C:\test\")
fileSaveName = ActiveSheet.Cells(1, 5) & " __ " & Cells(1, 8)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
MsgBox "File Saved " & " " & fileSaveName
End If
Application.StatusBar = False
End Sub
答案 0 :(得分:0)
在让代码继续之前,您需要检查ActiveSheet.Cells(1, 5)
和Cells(1, 8)
是否为空。为什么你没有在第二个条件下使用ActiveSheet
?没有那个限定词,你只是在寻找麻烦。