Hi all,
I’m having difficulty with the saving of an Excel file. Izandol kindly provided some code the other day but there is another unforeseen step which has convoluted matters so I thought it best to start a new thread.
I have an .xlsx file (FILE A) and whenever that is saved (AfterSave) I want it to save a copy of the file (FILE B) as an .xlsx in a different location as read-only with a password.
However even though I have put AppDisplayAlerts=False I still receive the message:
“A file named XXXX already exists in this location. Are you sure you want to save it?”
Whether I press Yes, No, or Cancel to the above message the macro just keeps looping and I eventually have to use Task Manager to quit Excel.
My code is:
Sub Workbook_AfterSave(ByVal Success As Boolean)
applicationdisplayalerts = False
ChDir "\\Filepath"
ActiveWorkbook.SaveAs Filename:= _
"\\Filepath\Copy.xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False, ReadOnlyRecommended:=True, ConflictResolution:=False, Password:="password"
applicationdisplayalerts = True
End Sub
Bookmarks