Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save File Dialog Prompts User Twice - Why?

Status
Not open for further replies.

Jen53403

Programmer
Jul 17, 2006
22
I have VB code which writes to an Excel file and uses a SaveFileDialog to allow the user to select the file name and location. If the file aleady exsists, it gives two warnings:

File <filename> already exists. Do you want to replace it?
(Yes / No)

The user clicks Yes, and then this one pops up:

A file named <filename> already exists in this location. Do you want to replace it?
(Yes / No / Cancel)

Here are relevant lines of code:
Code:
Private Sub SaveFileDialog1_FileOk(...) Handles SaveFileDialog1.FileOk
   If FileExists(filePath) Then
      BesTtoolbar.g_XlsApp.Application.Workbooks.Open(filePath)
   Else
      BesTtoolbar.g_XlsApp.Application.Workbooks.Add()
   End If
   ' Write some stuff to the file.
   BesTtoolbar.g_XlsApp.Application.ActiveWorkbook.Close(True, filePath)
End Sub
You can assume that FileExists() and filePath are what their names suggest.

Why is it giving two warnings, and how can I turn one of them off? I don't want users to get confused when I roll this out.

Thanks!
 
P.S. CheckFileExists and CheckPathExists are both false for SaveFileDialog1 in my code.
 
I would suggest stepping through the code and see where it hits, but likely your second one is coming from the BesTtoolbar control. Either it is doing it automatically or it talks directly to Excel (Excel will automatically propmt if the file exists).

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top