[英]How to print to pdf separated excel pages in one file?
I made this simples code, but this create 4 pdfs files, not only one, can you help me?我制作了这个简单的代码,但这会创建 4 个 pdfs 文件,而不仅仅是一个,你能帮我吗?
Sub PrintToPageX()
Worksheets("Anexo Financeiro").Select
Application.ActivePrinter = "Microsoft Print to PDF on Ne02:"
ActiveWindow.SelectedSheets.PrintOut from:=1, to:=4
If Worksheets("Anexo Financeiro").Range("p205") = 1 Then ThisWorkbook.PrintOut from:=5, to:=5
If Worksheets("Anexo Financeiro").Range("n272") = 1 Then ThisWorkbook.PrintOut from:=6, to:=6
ActiveWindow.SelectedSheets.PrintOut from:=7, to:=7
End Sub
Assuming that Worksheets("Anexo Financeiro")
is the same as ActiveWindow.SelectedSheets
which is the same as ThisWorkbook.ActiveSheet
:假设Worksheets("Anexo Financeiro")
与ActiveWindow.SelectedSheets
相同,即与ThisWorkbook.ActiveSheet
相同:
I created an If Statement that checks if the document can be printed all together or if it needs to be separated.我创建了一个If 语句,用于检查文档是否可以一起打印或者是否需要分开打印。
Sub PrintToPageX()
Application.ActivePrinter = "Microsoft Print To PDF on Ne02:"
With Worksheets("Anexo Financeiro")
If .Range("p205") = 1 And .Range("n272") = 1 Then
.PrintOut From:=1, To:=7
Else
.PrintOut From:=1, To:=4
If .Range("p205") = 1 Then .PrintOut From:=5, To:=5
If .Range("n272") = 1 Then .PrintOut From:=6, To:=6
.PrintOut From:=7, To:=7
End If
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.