[英]Print Multiple Excel sheets in a specific order
I am trying to print/publish multiple sheets from Excel workbook, but in a specific order. 我正在尝试从Excel工作簿中打印/发布多个工作表,但是要按特定的顺序进行。 I use the same code used here but it is not printing in the order I inputted into my array and alternatively is printing from leftmost sheet to the rightmost sheet.
我使用的代码与此处相同,但不是按照输入数组的顺序打印,而是从最左边的页面打印到最右边的页面。
Save multiple sheets to .pdf 将多张工作表保存到.pdf
I would like to print the sheets in a specific order. 我想按特定顺序打印纸。 I selected the order that I wanted to print, however, it printed from left most sheet and going to right in the way they were in the workbook.
我选择了要打印的顺序,但是,它从最左边的工作表开始打印,并按照它们在工作簿中的方式向右打印。 How can I make them print in the order that I inputted in the array.
如何使它们按照在数组中输入的顺序打印。
I selected 我选了
ThisWorkbook.Sheets(Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")).Select
But I got "4.1","CheckList GIT 400","GIT 399","TCCC","GIT 100" as the published document. 但是我得到了“ 4.1”,“ CheckList GIT 400”,“ GIT 399”,“ TCCC”,“ GIT 100”作为已发布的文档。
Any help would be much appreciated. 任何帮助将非常感激。
Just loop: 循环播放:
Sub Kakeda()
ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
For Each a In ary
Sheets(a).ExportAsFixedFormat Type:=xlTypePDF
Next a
End Sub
EDIT#1: 编辑#1:
This version will save the .pdf files separately: 此版本将分别保存.pdf文件:
Option Explicit
Sub Kakeda()
Dim ary
Dim a As Variant, fp As String
ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
fp = ActiveWorkbook.Path
For Each a In ary
Sheets(a).ExportAsFixedFormat Type:=xlTypePDF, Filename:=fp & "\" & a & ".pdf"
Next a
End Sub
EDIT#2: 编辑#2:
This version will create a single pdf 此版本将创建一个pdf文件
Option Explicit
Sub Kakeda3_TheSequel()
Dim ary
Dim a As Variant, fp As String
ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
fp = ActiveWorkbook.Path
For Each a In ary
Sheets(a).Move after:=Sheets(Sheets.Count)
Next a
ThisWorkbook.Sheets(ary).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF
End Sub
我认为这取决于纸张的顺序,使您要打印的纸张顺序(按顺序)可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.