[英]How do I change the file print setting on Excel to use VBA to print several pages when printing the workbook
I would like to change the file print setting in Excel to go directly to VBA and print some of the 26 worksheets while printing the workbook. 我想在Excel中将文件打印设置更改为直接转到VBA,并在打印工作簿时打印26个工作表中的一些。 Most of the active worksheets should print, but a few of the worksheets should not print.
大多数活动工作表应打印,但一些工作表不应打印。 The workbook is a template and the number of active and printed worksheets will change with each new workbook created.
该工作簿是一个模板,活动的和打印的工作表的数量将随创建的每个新工作簿而变化。 Lastly, should the VBA code go in the "ThisWorkbook" section?
最后,VBA代码是否应放在“ ThisWorkbook”部分中?
I would use something like 我会用类似的东西
Sub PrintSheets ()
Dim Wks1 as Worksheet: set Wks1=Sheets("SheetName1")
Wks1.PrintOut Copies:=1, Collate:=True
'[...] and so on with your sheets
Where the no of copies can be changed To fully automatize the code I usualy create a new sheet called "Macro keys" where I store the sheets' name and copy count (ie A1= "SheetName1", B1="5" , A2="SheetName2", B2="10"). 可以更改副本数的位置为了使代码完全自动化,我通常创建一个名为“宏键”的新表,在其中存储表的名称和副本数(即A1 =“ SheetName1”,B1 =“ 5”,A2 = “ SheetName2”,B2 =“ 10”)。 Thus:
从而:
Sub PrintSheets ()
Dim MacroKeys as Worksheet: Set MacroKeys = Sheets("Macrokeys")
SheetName1 = Macrokeys.Range("A1").Value
SheetName1_CopyCount = Macrokeys.Range("B1").Value
Sheet(SheetName1 ).PrintOut Copies:= SheetName1_CopyCount, Collate:=True
'[...] and so on with your sheets
End Sub
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.