Hi there,
I currently have a macro that opens all the files in a folder, formats the data within the sheet and then saves each file before moving on to the next.
This is the line where it saves each workbook.
ActiveWorkbook.Close SaveChanges:=True
I would like to Save the workbook with its current file name, add a password to open the file via an on screen prompt, and stop the file from always creating a backup once opened.
Thanks for your help!!!
The full code,
Sub RUNMACROALLFILES()
Dim objFSO, fso
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = objFSO.GetFolder("F:\WhereMyStuffLives\")
Application.ScreenUpdating = False
For Each myFile In myFolder.Files
If myFile.Name Like "*.xlsx" Then
Workbooks.Open Filename:=myFile
For Each sh In ActiveWorkbook.Sheets
Application.Run ("PERSONAL.XLSB!FORMAT_ACCESS_QRY")
Next
ActiveWorkbook.Close SaveChanges:=True
End If
Next
Application.ScreenUpdating = True
End Sub
Bookmarks