批量打印本文件夹内除本工作簿以外所有工作簿的第一个工作表

 

Sub Sample()
Dim MyPath As String
Dim MyBook
Application.DisplayAlerts = False
MyPath = ThisWorkbook.Path
MyBook = Dir(MyPath & "\*.xlsx")
Do While MyBook <> ""
    If MyBook <> ThisWorkbook.Name Then
        With Workbooks.Open(MyBook)
            .Sheets(1).PrintOut
            .Close
        End With
    End If
    MyBook = Dir
Loop
Set MyBook = Nothing
Application.DisplayAlerts = True
End Sub

  

posted @ 2021-05-12 17:03  熬肥妖  阅读(101)  评论(0编辑  收藏  举报