|
- Sub Main()
- Dim strPath As String
- With Application.FileDialog(msoFileDialogFolderPicker)
- .InitialFileName = ThisWorkbook.Path
- If .Show Then strPath = .SelectedItems(1) Else Exit Sub
- End With
- If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
- 'strPath = ThisWorkbook.Path
- DoApp False
- Dim i As Long, iCount As Long
- Dim objFso As Object, vrtFiles(1 To 2345) As String
-
- Set objFso = CreateObject("Scripting.FileSystemObject")
- GetFiles strPath, objFso, vrtFiles, iCount, "$", "*.xlsm"
- Set objFso = Nothing
- For i = 1 To iCount
- Workbooks.Open(vrtFiles(i), 0).SaveAs Split(vrtFiles(i), ".xls")(0), 51
- ActiveWorkbook.Close
- Kill vrtFiles(i)
- Next
- DoApp
- Beep
- End Sub
- Function GetFiles(strPath As String, objFso As Object, vrtFiles() As String, iCount As Long, strExclude As String, Optional strFilter As String = ".xls")
- Dim objSubFolder As Object, objFilterFile As Object
- For Each objFilterFile In objFso.GetFolder(strPath).Files
- If objFilterFile.Name Like strFilter Then
- If InStr(objFilterFile.Name, strExclude) = 0 Then
- iCount = iCount + 1
- vrtFiles(iCount) = objFilterFile.Path
- End If
- End If
- Next
- For Each objSubFolder In objFso.GetFolder(strPath).SubFolders
- GetFiles objSubFolder.Path, objFso, vrtFiles, iCount, strExclude, strFilter
- Next
- End Function
- Function DoApp(Optional Flag As Boolean = True)
- With Application
- .ScreenUpdating = Flag
- .DisplayAlerts = Flag
- If Flag Then .Calculation = xlCalculationAutomatic Else .Calculation = xlCalculationManual
- .EnableEvents = Flag
- End With
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|