VBA Error9导出到PDF
使用Excel VBA,我试图以PDF格式打印一张工作簿。
我正在使用这个代码:
Private Sub cmd_Print_Design_Click() Sheets("Sheet1").ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=ThisWorkbook.Path & "/" & "Design Summary", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=True End Sub
该代码不运行,我得到ERROR 9 "Subscript out of Range"
。 我不明白如何解决它。
在Windows下,path分隔符是一个反斜杠\
所以改变这行代码:
Filename:=ThisWorkbook.Path & "/" & "Design Summary",
至
Filename:=ThisWorkbook.Path & "\" & "Design Summary",