我试图将多个工作表保存为单个pdf文件 以下宏使用表格名称,但它不适合我,因为我的表格有动态名称。试图使用Sheets(1)寻址,但没有奏效。有没有人有任何想法?
Sub export_to_pdf()
Sheets(Array("Configuration", "chart")).Copy
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="filename.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
ActiveWorkbook.Close (False)
End Sub
答案 0 :(得分:3)
使用
Sheets(1).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="filename.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
或者如果您有更多
Sheets(Array(1, 2, 5)).Copy
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="filename.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
ActiveWorkbook.Close (False)
答案 1 :(得分:0)
您的程序代码适用于我,稍有更改,请在此处显示。
Sub export_to_pdf()
Sheets(Array("Sheet1", "Sheet2")).Copy 'Change to your sheets
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="filename.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _ 'changed to True
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
ActiveWorkbook.Close (False)
End Sub
在这种情况下,我也在Microsoft Word Object Library
Tools
Reference
的引用