select所有表格并打印成一个pdf文件

我想打印所有工作表到一个PDF文件。 每张纸将在新的页面的开始。

我试过:

Private Sub CommandButton9_Click() ActiveWorkbook.Sheets.Select With Selection .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "E:\tempo.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _ IgnorePrintAreas:=False, OpenAfterPublish:=True End With End Sub 

我有一个消息:“方法'select'对象'表'失败。”

谢谢!

而不是activesheet.export...使用activeworkbook.export...每个工作表将显示您如何具有每个工作表集的打印设置。

或者使用variables如:

 Sub Button1_Click() Dim wb As Workbook, Fnm As String Set wb = ThisWorkbook Fnm = "C:\Users\Dave\Downloads\TestMe.pdf" wb.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fnm End Sub