以下代码会导致“文档未保存”错误:
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
关于excel - 在 VBA 上另存为 PDF 文件返回 "Document not saved"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16972766/