vba 用于打印所有工作簿工作表的 Excel VB 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5693189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel VB script to print all workbooks' sheets
提问by xain
is there using excel's vb script (or macros) to print all its sheets to a given printer ? The number of sheets is variable.
是否使用 excel 的 vb 脚本(或宏)将所有工作表打印到给定的打印机?页数是可变的。
Excel's version is 2007.
Excel 的版本是 2007。
Thanks
谢谢
采纳答案by jonsca
See if something like thisis what you are looking for. You'd just need to set up a loop to select all of the sheets, and use that select false
method on all but the first.
看看是否有这样的是你在找什么。您只需要设置一个循环来选择所有工作表,并select false
在除第一个之外的所有工作表上使用该方法。
Here's what I cobbled together (I did not test it extensively, and my VBA is a little rusty)
这是我拼凑出来的(我没有对其进行广泛的测试,而且我的 VBA 有点生疏)
Sub loopandprint()
Dim ws As Worksheet
Dim i As Integer
i = 0
For Each ws In ActiveWorkbook.Worksheets
If (i = 0) Then
ws.Select
Else
ws.Select False
End If
i = i + 1
Next ws
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub