您好我目前有一个脚本可以将PDF导出到某个范围,以便在一个文档中导出两个页面。目前我将A1:W44导出为一页,并希望将A44:W44导出为同一文档的第二页。
理想情况下,当W44 = 2的值时,我想向Print_Range()添加一个IF函数来更改打印输出2页(从A1:W44是第1页,A45:W88是第2页)。任何帮助都会非常感谢。
Sub set_variables()
reportsht = "report"
strow = 2
slopessht = "slopes"
Set reportrng = Range("A1:W44")
xpath = Application.ActiveWorkbook.Path
End Sub
Sub print_range()
Call set_variables
stval = Sheets(reportsht).Range("z7")
endval = Sheets(reportsht).Range("z8")
For i = stval + strow - 1 To endval + strow - 1
siteid = Sheets(slopessht).Cells(i, 2)
If siteid = "" Then Exit For
'create sheet
Call createsht(siteid)
Next i
End Sub
Sub createsht(siteid)
pdffilename = xpath & "\" & siteid & ".pdf"
Sheets(reportsht).Range("z5") = siteid
Calculate
reportrng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdffilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=True, _
From:=1, to:=1, OpenAfterPublish:=False
End Sub
由于