简体   繁体   English

保存工作表 pdf excel vba

[英]save sheet pdf excel vba

i have the following vba codes我有以下 vba 代码

Sub SaveAsPDF()
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String

strPathLocation = Worksheets("Sheet1").Range("A2").Value
strFilename = Worksheets("Sheet1").Range("A4").Value
strPathFile = strPathLocation & strFilename
Sheets("Sheet2").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPathLocation & strFilename & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub

what i want to achieve is to save Sheet2 as pdf to the specified path and specified file name我想要实现的是将 Sheet2 保存为 pdf 到指定的路径和指定的文件名

Try that.试试那个。

Select in vba your sheet and use this function to export, the filename you could pass as a parameter in the function.在 vba 中选择您的工作表并使用此函数导出,您可以在函数中作为参数传递的文件名。

Sub ExportarPDF()

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="yourpath.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM