Use something like
If Dir(SaveFileName) < vbNullString Then
' file exists
Else
' file does not exist
End If
Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Mon, 1 Dec 2008 12:29:11 -0800 (PST), Fan924
wrote:
I am using the following to select a file name and then open file for
writing. It writes to the filename even if it is already used. Is
there a way to have it check before overwriting file? Examples?
________________________________
SaveFileName = Application.GetSaveAsFilename("C:\My Documents
\temp.hex", _
"Hex File (*.hex), *.hex", , "Save File As:")
Open SaveFileName For Output As #1
________________________________