将工作薄每一个工作表导出为PDF文件。
Sub PDF() Dim asy As Worksheet Dim spath As String spath = Excel.ThisWorkbook.Path For Each asy In Excel.ThisWorkbook.Worksheets sName = spath & "\" & asy.Name & ".pdf" asy.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sName Next End Sub
将当前工作表导出为PDF文件。
Sub PDF() spatch = Excel.ThisWorkbook.Path sName = spatch & "\" & ActiveSheet.Name & Format(Date, "yyyymmdd") ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sName End Sub
VBA 参考文档
https://msdn.microsoft.com/zh-cn/VBA/Excel-VBA/articles/workbook-exportasfixedformat-method-excel