遍历一个文件夹内的所有EXCEL工作簿,找出同名的例如每个工作簿中Sheet2这张工作表全部打印出来的VBA。 30
下面这段函数运行的时候出现438错误和1004错误,请帮忙看下,谢谢。Subprt()DimwsAsWorkbook,path$,d$Application.Screen...
下面这段函数运行的时候出现 438错误和 1004错误,请帮忙看下,谢谢。
Sub prt()
Dim ws As Workbook, path$, d$
Application.ScreenUpdating = False
path = ThisWorkbook.path & "\"
d = Dir(path & "*.xls")
Do While d <> "'"
If d <> ThisWorkbook.Name Then
Set ws = Workbooks.Open(path & d)
ws.Sheets("sheet2").PrintOut
ws.Close False
End If
d = Dir
Loop
Application.ScreenUpdating = True
End Sub 展开
Sub prt()
Dim ws As Workbook, path$, d$
Application.ScreenUpdating = False
path = ThisWorkbook.path & "\"
d = Dir(path & "*.xls")
Do While d <> "'"
If d <> ThisWorkbook.Name Then
Set ws = Workbooks.Open(path & d)
ws.Sheets("sheet2").PrintOut
ws.Close False
End If
d = Dir
Loop
Application.ScreenUpdating = True
End Sub 展开
1个回答
展开全部
修改为:
Sub prt()
Dim ws As Workbook, path$, d$
Application.ScreenUpdating = False
path = ThisWorkbook.path & "\"
d = Dir(path & "*.xls")
Do While d <> ""
If d <> ThisWorkbook.Name Then
Set ws = Workbooks.Open(path & d)
ws.Sheets("sheet2").PrintOut
ws.Close False
End If
d = Dir
Loop
Application.ScreenUpdating = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询