使用VBA 批量打印同一文件夹下所有工作簿中的“报表”工作表,并把每张表调整打印在一页上
附件下载百度网盘链接 http://pan.baidu.com/s/1bng48m7
希望得到大家的帮助
如何使用VBA 批量打印同一文件夹下所有工作簿中的“报表”工作表,并把每张表调整打印在一页上
答案:2 悬赏:10 手机版
解决时间 2021-03-02 13:51
- 提问者网友:十年饮冰
- 2021-03-01 18:00
最佳答案
- 五星知识达人网友:雾月
- 2021-03-01 19:08
可利用如下代码批量打印:
Sub Print_All_Excel()
On Error Resume Next
Dim my_Doc As String
Dim my_File As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
.AllowMultiSelect = False
my_Doc = .SelectedItems(1)
End With
my_File = Dir(my_Doc & "\" & "*.xls*")
Do While Len(my_File) <> 0
Workbooks.Open (my_Doc & "\" & my_File)
ActiveWorkbook.Worksheets("报表").Selected
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWorkbook.Close
my_File = Dir
Loop
End Sub
Sub Print_All_Excel()
On Error Resume Next
Dim my_Doc As String
Dim my_File As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
.AllowMultiSelect = False
my_Doc = .SelectedItems(1)
End With
my_File = Dir(my_Doc & "\" & "*.xls*")
Do While Len(my_File) <> 0
Workbooks.Open (my_Doc & "\" & my_File)
ActiveWorkbook.Worksheets("报表").Selected
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
ActiveWorkbook.Close
my_File = Dir
Loop
End Sub
全部回答
- 1楼网友:你哪知我潦倒为你
- 2021-03-01 19:50
sub 批量打印()<br>dim myfiles<br>dim i as long, path<br> with application.filedialog(msofiledialogfolderpicker)<br> .title = "请选择要查找的文件夹"<br> if .show then<br> path = .selecteditems(1)<br> end if<br> end with<br>myfiles = dir(path & "\*.xlsx")<br>on error resume next<br>application.screenupdating = true<br>application.displayalerts = false<br>do while right(myfiles, 5) = ".xlsx"<br>i = i + 1<br>workbooks.open filename:=path & "\" & myfiles<br>sheets("报表").select<br><br>activewindow.view = xlpagebreakpreview<br>activewindow.selectedsheets.printout copies:=1, collate:=true, _<br> ignoreprintareas:=false<br>activewindow.close<br><br>myfiles = dir<br><br>loop<br>end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯