[英]Print multiple pages (loop in a worksheet) in one pdf
I have the following problem with a VBA-Script which I haven't written:我没有编写的 VBA 脚本有以下问题:
It's a loop where the loop fills the printarea of the ws with information (page 1 fe) --> prints the page 1 --> fills the the printarea of the ws with the next information (page 2 fe) --> prints the page 2 and on and on and on.这是一个循环,其中循环用信息(第 1 页)填充 ws 的打印区域 --> 打印第 1 页 --> 用下一个信息(第 2 页)填充 ws 的打印区域 --> 打印第 2 页等等。 I do have the option to tell the loop from which page it should start and when to end:
我确实可以选择告诉循环应该从哪个页面开始以及何时结束:
** My goal is to have all the pages I want to be saved in one pdf - is that possible?** ** 我的目标是将我想要保存的所有页面都保存在一个 pdf 中——这可能吗?**
Here is the code:这是代码:
Private Sub CommandButton6_Click()
Dim Start
Dim Ende
Dim X1 As Integer
Dim ST1 As Integer
Dim End1 As Integer
X1 = 0
Start = InputBox("Auf welcher Seite soll der Ausdruck beginnen ?", MSGTitel)
If Start <> "" Then
If IsNumeric(Start) = True Then
Ende = InputBox("Bis zu welcher Seite soll gedruckt werden ?", MSGTitel)
If Ende <> "" Then
If IsNumeric(Ende) = True Then
If Start > Ende Then
ST1 = Ende
End1 = Start
Else
ST1 = Start
End1 = Ende
End If
Do Until ST1 + X1 = End1 + 1
Tabelle6.Cells(11, 2).value = (Val(ST1 + X1) * 20) - 19
Label1.Caption = Val(ST1 + X1)
Tabelle6.Cells(6, 31).value = Label1.Caption
'Debug.Print Label1.Caption
Tabelle6.PrintOut
X1 = X1 + 1
Loop
End If
End If
End If
End If
End Sub
Thanks for your help谢谢你的帮助
Tried to change the print method or instead of printing to save it as a pdf but I struggle with the loop as all my pdfs only have one page in it试图更改打印方法或不打印以将其另存为 pdf 但我在循环中挣扎,因为我所有的 pdf 都只有一页
It is not possible with PrintOut method, if your sheet Tabelle6 contains only one page.如果您的工作表 Tabelle6 仅包含一页,则使用 PrintOut 方法是不可能的。 Your problem cannot be simply solved with VBA.
您的问题不能简单地用 VBA 解决。
You can try other solution: Rewrite VBA-script so that your loop, instead of PrintOut method, copies contents of Tabelle6 on new sheet, one page after (below) previous page, and then prints the whole new sheet, after the loop is finished (you need to take care of page breaks on new sheet, so that print looks like what you expect)您可以尝试其他解决方案:重写 VBA 脚本,以便您的循环而不是 PrintOut 方法在新工作表上复制 Tabelle6 的内容,在前一页(下)一页之后,然后在循环完成后打印整个新工作表(您需要处理新工作表上的分页符,以便打印看起来像您期望的那样)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.