我尝试将一系列单元格导出为pdf,并使用预设名称将其保存到set文件夹。我只使用的代码将创建一个pdf并询问我想要保存的位置。有什么建议吗?
Sub ExcelToPDF()
Range("A11:D57").Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, fileName:="C:\Documents\Plantwide\Document Managerment Control\File Name", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
答案 0 :(得分:0)
我发现了我的错误。以下是正确的代码:
Sub ExcelToPDF()
Dim myFilename As String
myFilename = "C:\Documents\Plantwide\Document Managerment Control\" & Range("B3") & " - " & Format(Range("B1"), "mm.dd.yyyy") & " - Final Report"
Range("A11:D57").Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, fileName:=myFilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub