我创建了一个宏以将excel保存为PDF。该代码对我有用,但是,我想禁用保存的备份excel文件(每次保存时,它都会创建一个名为Book1,Book2等的新工作簿)。
我了解Workbook.CreateBackup=False
,但是我不知道如何在导出的文件上实现(相对于SaveAs)。我已经搜索了多个论坛,但找不到答案。
Sub SaveAsPDF()
Dim tsR As String
Dim serialNo As String
Dim xStrDate As String
Dim myFileN As String
tsR = "TS256359_Report_"
serialNo = Range("N7") & ""
xStrDate = Format(Now, "mm-dd-yyyy hh-mm-ss AM/PM")
myFileN = tsR & serialNo & "(" & xStrDate & ")"
With Application
.ScreenUpdating = False
Application.DisplayAlerts = False
ThisWorkbook.Sheets("WC Worksheet").Activate
ActiveSheet.Copy
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"C:\Users\e356881\Desktop\8540 Worksheets\" & myFileN, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
Application.DisplayAlerts = True
End Sub
我希望将文件保存为PDF时,不会创建其他excel工作簿。