How to use workbook.saveas with automatic Overwrite
Here is the best solution :
Through neither identify the prompt set xls.DisplayAlerts = False
This ConflictResolution is neither a true or false property, it may be xlLocalSessionChanges . However this has blank to do along displaying the Overwrite prompt.
Set xls = CreateObject("Excel.Application") xls.DisplayAlerts = False Set wb = xls.Workbooks.Add fullFilePath = importFolderPath & "\" & "A.xlsx" wb.SaveAs fullFilePath, AccessMode:=xlExclusive,ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges wb.Close (True)
Delete the file it exists, previously executing SaveAs.
If Dir("f:ull\path\with\filename.xls") <> "" Then Kill "f:ull\path\with\filename.xls" End IfIt is simple than setting DisplayAlerts off and on, and if DisplayAlerts remains off while code bang, In case work with Excel in the same session, it can originator problems.