Excel 怎么用宏完成打开一个文件夹的所有文件然后再关闭
1个回答
展开全部
On Error GoTo 1
Dim K1 As Object
Set K1 = CreateObject("Scripting.FileSystemObject")
Set k2 = K1.GetFolder(ThisWorkbook.Path)
Set xlApp = CreateObject("Excel.Application")
Dim Xrow As Integer
Xaces = 3
For Each f In k2.Files
If InStr(f.Name, ThisWorkbook.Name) = False Then
Xrow = 3
Ca = ThisWorkbook.Path & "\" & f.Name
Set xlbook = xlApp.Workbooks.Open(Ca)
xlApp.Visible = False
’可插入需要进行操作的代码
xlbook.Close
End If
Next
Exit Sub
1:
xlbook.Close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询