Hi,
There are a few things to consider:
First, if I understand you properly, you are using the common dialog to get a path & filename from the user. Through this dialog, you should get the "File exists, overwrite..." prompt. Saying no, will bring you back in the dialog to give another name.
Second, once you've left the common dialog, there are only two options: either the user has given you a filename (and OK'd overwriting if it is an existing file), or the user cancelled.
Third, you can disable the default Excel overwrite prompt. Note that this is an application wide setting that is stored in the registry, and should be reset after use.
So if you check how the user left the dialog, you should be OK in saving without the default Excel overwrite prompt. In code this should look something like this:
On Error Resume Next
dlgCommonDialog.ShowSave
'Check if the user left the dialog through the Cancel-button
If Err.Number = 32755 Then
'Do nothing & re-enable error-handling
On Error GoTo 0
Else
sFileName = dlgCommonDialog.FileName
'Temporarily disable Excel overwrite prompt
Application.displayAlerts = False
oExcel.Workbooks(1).SaveAs sFileName
'Re-enable Excel overwrite prompt
Application.DisplayAlerts = True
End If
I hope this helps, otherwise let me know.
Erwin
Enter your message below
Sign in or Join us (it's free).