|
Sub OpenCloseArray()
Dim MyFile As String
Dim Arr(100) As String
Dim count As Integer
MyFile = Dir("d:\zcxiao\Desktop\132\" & "*.xlsx")
count = count + 1
Arr(count) = MyFile
Do While MyFile <> ""
MyFile = Dir
If MyFile = "" Then
Exit Do
End If
count = count + 1
Arr(count) = MyFile '将文件的名字存在数组中
Loop
For i = 1 To count
Workbooks.Open Filename:="d:\zcxiao\Desktop\132\" & Arr(i) '循环打开Excel文件
Cells(1, 1) = "alex_bn_lee" '修改打开文件的内容(修改的不是我循环打开Excel文件的内容,变成了修改1222.xlsm的内容,我把这句改成Workbooks.(Arr(i)). Cells(1, 1) = "alex_bn_lee"这个格式可能是不对,正确的格式应该是怎样的???
ActiveWorkbook.Close savechanges = True '关闭打开的文件
Next
End Sub
手机不能传附件,请谅解。
求大神答疑! |
|