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

From: Harold (haroldk_at_microsoft.com)
Date: 04/07/04


Date: Wed, 7 Apr 2004 08:06:39 -0500

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
haroldk@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.1264@TK2MSFTNGP10.phx.gbl...
> 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
>
>


Relevant Pages

  • Re: SaveAs with Prompt (no overwrite w/o prompt!!)
    ... Dir$ is a lot faster than using FileSearch. ... overwrite. ... the ufmSave form saves using SaveAs method. ... >> I could get a prompt before overwriting. ...
    (microsoft.public.word.vba.customization)
  • Re: Overwriting an existing Excel workbook
    ... *always* got an overwrite prompt from VBA with the test code that I ... Dave Peterson schreef: ... And the Conflictresolution setting has to do with shared workbooks. ...
    (microsoft.public.excel.misc)
  • Re: excel object
    ... Thanks for the reply but which one do I use to overwrite an existing file ... without a prompt. ... This script will be scheduled. ... In order to crete an excel object do I have to have excel ...
    (microsoft.public.scripting.vbscript)
  • Re: SaveFileDialog.ShowDialog() returns Cancel when Yes to overwri
    ... I am using the SaveFileDialog out of a *.exe that does not have a GUI ... The workaround I found is to just disable the overwrite prompt ... a bug in your own code that makes the return value looks bad when it is ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Great SWT Program
    ... Plus it prompts me whether to overwrite one if I pick ... the odds are 100% that emacs will ask you whether you want ... The prompt looks something like: ... [Bent tacitly admits that his professional needs include an elitist ...
    (comp.lang.java.programmer)