我正在使用输入模板,我想将Sheet 3保存为具有不同名称的PDF文件(在保存文件系统之前必须询问路径和文件名)。在这里,我创建了一些代码,请帮助解决这个问题。
Sub Mac()
Dim wsh As Worksheet, vWshs, DossierEvaluationkit
vWshs = Array("Dossier Evaluation Template")
With ActiveWorkbook
For Each DossierEvaluationkit In vWshs
.Worksheets(DossierEvaluationkit).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\s0900993\Desktop\Lateral DEK" & LateralDossierEvaluationkit, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next DossierEvaluationkit
End With
End Sub
答案 0 :(得分:2)
最好将Application.GetSaveAsFileName
用于此类案件。
Sub GetSaveAsFilename()
Dim fileName As String
fileName = Application.GetSaveAsFilename(InitialFileName:="", _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Path and FileName to save")
If fileName <> "False" Then
With ActiveWorkbook
.Worksheets("Dossier Evaluation Template").ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
fileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
End If
End Sub