VBA将当前的表格存储成PDF文件进行存储
代码
- Sub ExportToPDF()
- Dim FilePath As String
- Dim FileName As String
- Dim ExportRange As Range
-
- ' 设置导出文件路径及名称
- FilePath = "D:\Users\"
- FileName = "ExportedPDF"
-
- ' 设置导出区域范围
- Set ExportRange = Range("B1:BE38")
-
- ' 导出区域到 PDF 文件
- ExportRange.ExportAsFixedFormat Type:=xlTypePDF, _
- Filename:=FilePath & FileName & ".pdf", Quality:=xlQualityStandard, _
- IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
- End Sub