|
Sub xqoa2() '不知道怎么修改代码,请老师修改
Dim Arr(1 To 10000), myPath$, myFile$, AK As Workbook, i As Integer, j&
Set ShApp = CreateObject("Shell.Application")
Set Path1 = ShApp.BrowseForFolder(0, "请选择文件夹", 0, 0)
If Path1 Is Nothing Then Exit Sub
myPath = Path1.items.Item.Path & "\"
myFile = Dir(myPath & "\*.xlsx")
On Error Resume Next
Do While myFile <> ""
If myFile Like "*.xlsx" Then
i = i + 1
Arr(i) = myPath & myFile
End If
myFile = Dir
Loop
If i Then
Application.ScreenUpdating = False
Application.DisplayAlerts = False
myPath = ThisWorkbook.Path & "\结果\"
For j = 1 To i
myFile = Split(Arr(j), "\")(UBound(Split(Arr(j), "\")))
Workbooks.Open Arr(j)
ActiveWorkbook.SaveAs Filename:= _
myPath & Left(myFile, Len(myFile) - 1), FileFormat:=xlExcel8, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Next j
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "全部转换完毕,共转换文件 " & i & "个"
End If
Erase Arr
End Sub |
|