Senso
Inventaris
- Lid geworden
- 13 jun 2016
- Berichten
- 11.283
- Besturingssysteem
- W10 Pro en W11 Pro
- Office versie
- Office 2007 H&S en Office 2021 Prof Plus
Ik heb een map vol van deze oude 97-2003 bestanden. Heeft iemand een tool/VBA?
If you have many files, you can create a single macro to automate the process of converting a folder full of .xls files to the .xlsm format, according
Gevonden onderstaande. Kan dit?
If you have many files, you can create a single macro to automate the process of converting a folder full of .xls files to the .xlsm format, according
Gevonden onderstaande. Kan dit?
PHP:
Option Explicit
Option Private Module
Sub Main()
Dim strFolder As String
' browse for a folder
strFolder = BrowseOneFolder(ThisWorkbook.Path)
' nothing is selected
If strFolder = "" Then
Exit Sub
End If
' speed up Macro
Application.ScreenUpdating = False
Application.Cursor = xlWait
' rename files in the folder
ProcessFolder strFolder
' bring macro back to normal setting
Application.Cursor = xlDefault
Application.ScreenUpdating = True
' show completion message
MsgBox "Done", vbInformation, ""
End Sub
Sub ProcessFolder(FolderName As String)
Dim objFSO As Object
Dim objFolder As Object
Dim objSubfolder As Object
Dim objFile As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderName)
' process current folder
For Each objFile In objFolder.Files
If objFSO.GetExtensionName(objFile.Path) = "xls" Then
RenameXLStoXLSX objFile
End If
Next
' process all subfolders
For Each objSubfolder In objFolder.SubFolders
ProcessFolder CStr(objSubfolder)
Next
' dispose the objects
Set objFolder = Nothing
Set objFSO = Nothing
End Sub
Sub RenameXLStoXLSX(CurrentFileName)
Dim wbkXLSfile As Workbook
Dim strCurrentFileExt As String
Dim strNewFileExt As String
Dim strNewFileName As String
' initialize variable
strCurrentFileExt = ".xls"
strNewFileExt = ".xlsm"
strNewFileName = Replace(CurrentFileName, strCurrentFileExt, strNewFileExt)
' open the original file
Set wbkXLSfile = Application.Workbooks.Open(CurrentFileName, ReadOnly:=True, AddToMru:=False)
' always overwrite existing file
Application.DisplayAlerts = False
' save to new file format
wbkXLSfile.SaveAs Filename:=strNewFileName, _
FileFormat:=xlOpenXMLWorkbook, _
CreateBackup:=False
Application.DisplayAlerts = True
' close the file
wbkXLSfile.Close False
End Sub
Laatst bewerkt: