使用dir可以编列文件夹,一般结构是:
path="d:\xls\"filename=dir(path & "*.xls*")
while filename<>""
set wb=workbooks.open(path & filename)
wb.sheets.add
wb.save
wb.close
filename=dir
wend
修改为:
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)