1
我需要将多个Excel工作表导出到一个PDF文件中。我目前使用以下内容:使用VBA在多个Excel工作表中创建不同范围的PDF
Sub CreatePDF()
Sheets("ReportPage1").Select
Range("Print_Area").Select
Sheets("ReportPage2").Select
Range("Print_Area").Select
Sheets("ReportPage3").Select
Range("Print_Area").Select
ThisWorkbook.Sheets(Array("ReportPage1", "ReportPage2", "ReportPage3")).Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:="C:\temp\temp.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Sheets("ReportPage1").Select
Range("A1").Select
End Sub
问题是所有打印区域都不相同。生成的PDF使用ReportPage1中所有页面的打印区域的范围地址。
我尝试了Excel本身,在VBA之外,当我选择了ReportPage1!A1:E30和ReportPage2!A1:F70时,当我选择这两个工作表时,它会将选定范围更改为ReportPage1!A1 :E30和ReportPage2!A1:E30。
任何想法如何解决这个问题?
任何帮助将不胜感激。
而不是做Selection.exportasfixedformat。你能不能把它改成application.exportasfixedFormat,然后用To和From来选择你需要的页面? – Sam
或workbook.exportasfixedformat ... – Sam
谢谢,但这些都不会工作,我相信。请记住,我需要从每张表格中选择特定区域。 – RogB