vba實用操做代碼(打印工做表)

hetong文件下打印全部"專項經費使用範圍"工做表

Sub Macro1()
  Dim fn As String, wb As Workbook, ws As Worksheet, i As Long
  fn = Dir("C:\Users\fuxingyu\Desktop\hetong\*.xlsx")
  Do While fn <> ""
    Set wb = Workbooks.Open("C:\Users\fuxingyu\Desktop\hetong\" & fn)
    For Each ws In wb.Worksheets
        If Right(Trim(ws.Range("A1")), 8) = "專項經費使用範圍" Then
            ws.PrintOut copies:=1
        End If
    Next ws
    wb.Close
    fn = Dir
  Loop
  
  End Sub
相關文章
相關標籤/搜索