在VBA上保存为PDF文件返回“文档未保存”错误
以下代码会导致“文档未保存”错误:
sFileName = "C:\test.pdf" Application.DisplayAlerts = False wkbPDF.Worksheets.Select ActiveSheet.ExportAsFixedFormat Type := xlTypePDF, Filename := gsPDF_DIR & sFileName, _ Quality:=xlQualityStandard, IncludeDocProperties := True, _ IgnorePrintAreas := False, OpenAfterPublish := False Application.DisplayAlerts = True
但是在VBA之外做到这一点却是成功的(但是从工作簿包含100多张开始,这需要几分钟的时间)。
如果gsPDF_DIR
具有任何值,则Filename:
参数将不会有效,因为sFileName
已经指定了驱动器,文件夹和文件名。
尝试使用Filename := sFileName