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:
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!
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
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!