Trying to figure out how to save all excel files in a selected folder as Macro enabled workbooks. If possible, I want to just save down the macro enabled workbooks to replace all the excel files in the folder. at the moment i only have code to open one excel file in a folder - i can't figure out how to save the open workbook down as a macro enabled workbook, never mind looping through a whole folder. This is the code i have, it works on one file if i use an if statement rather than a do while loop for opening one file. It says there's an error with file = dir in the do while loop:
Sub SaveAllAsMacroWkbks()
Dim wb As Workbook
Dim myPath As String
Dim myFile As String, macFile As String
Dim myExtension As String, macExt As String
Dim FldrPicker As FileDialog
'Optimize Macro Speed
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'Retrieve Target Folder Path From User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & "\"
End With
'In Case of Cancel
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
'Target File Extension (must include wildcard "*")
myExtension = "*.xls*"
macExt = "*.xlsxm"
'Target Path with Ending Extention
myFile = Dir(myPath & myExtension)
macFile = Dir(myPath & macExt)
'Loop through each Excel file in folder
Do While myFile <> ""
Set wb = Workbooks.Open(Filename:=myPath & myFile)
'wb.saveAs FileName:=macFile, FileFormat:=52
'wb.Close SaveChanges:=True
'Get next file name
myFile = Dir
Loop
ResetSettings:
'Reset Macro Optimization Settings
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub