Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SaveAs with Prompt (no overwrite w/o prompt!!)

1,011 views
Skip to first unread message

zSplash

unread,
Apr 6, 2004, 12:35:13 PM4/6/04
to
According to Help, if you use SaveAs, you don't get a prompt to overwrite.
("If a document with the specified FileName already exists, the document is
overwritten without the user being prompted first.")

I have made a userform (ufmSave)that requires the save to be of a certain
format. In my code, the ufmSave form saves using SaveAs method.

The trouble is, someone saves a file with a certain name; later on, someone
else saves their file (using the ufmSave formatting requirements), and it
overwrites the initial file. So, the first guy has lost his work. If only
I could get a prompt before overwriting. Any suggestions, guys?

TIA


Dave Lett

unread,
Apr 6, 2004, 1:12:17 PM4/6/04
to
Hi zSplash,

You might be able to use something like the following:

Dim sFileName As String

sFileName = "C:\Test\Test.doc"
If Dir$(sFileName) <> "" Then
''' prompt because the file already exists
Else
''' the file doesn't exist, so safe to save
End If

HTH,
Dave

"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:OjU7jU$GEHA...@TK2MSFTNGP10.phx.gbl...

Peter Hewett

unread,
Apr 6, 2004, 5:05:13 PM4/6/04
to
Hi zSplash

Sounds like you're using a document when you should be using a template. If you
create new documents from the template then you avoid the overwriting of the
original document issue.

HTH + Cheers - Peter

JB

unread,
Apr 7, 2004, 7:15:44 AM4/7/04
to
You could always use the fs object to check for teh existance of the file
before you save it and have some error checking in your save routine?

J


"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:OjU7jU$GEHA...@TK2MSFTNGP10.phx.gbl...

Harold

unread,
Apr 7, 2004, 9:06:39 AM4/7/04
to
I would suggest testing to see if the file already exists. One reply
suggested using the fs object (fileSystem Object) which will work fine.
Another option is to use the FileSearch from within Word.
This is a sample using the FileSearch Property
Sub foo()
With Application.FileSearch
.FileName = "[document name]"
.Execute
If .FoundFiles.Count > 0 Then
MsgBox "File Already Exists!"
End If
End With

End Sub

do a search in VBA help for FileSearch for more information.
regards,

--
Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
har...@microsoft.com

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:OjU7jU$GEHA...@TK2MSFTNGP10.phx.gbl...

Dave Lett

unread,
Apr 7, 2004, 10:09:26 AM4/7/04
to
Hi Harold,

FYI and FWIW, Dir$ is a lot faster than using FileSearch.

Dave

"Harold" <har...@microsoft.com> wrote in message
news:%23ex8lEK...@tk2msftngp13.phx.gbl...

zSplash

unread,
Apr 19, 2004, 1:38:46 PM4/19/04
to
Thanks, guys. Witih all your help, I was able to solve the problem. I
really appreciate all the help.

st.

"zSplash" <zNOSPAMSplash@ gci.net> wrote in message
news:OjU7jU$GEHA...@TK2MSFTNGP10.phx.gbl...

0 new messages