How to save file and automatically overwrite an existing file without prompt in VBA macro

This is how to run the FileSaveAs command in VBA macro which is commonly used in Ms Excel or Ms Project without having the application prompt for overwriting and existing file.

The idea is to temporarily setting the object "Application.DisplaysAlerts" to false and then set it back to true after the file save.


Application.DisplayAlerts = False
FileSaveAs command
Application.DisplayAlerts = True