View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default GetSaveAsFileName to prompt for overwriting?

Alternatively, put the GetSaveAsFileName inside a Do Loop. When the user
inputs a file name, do Dir() or the equivalent to see if the file exists. If
so, offer the choice of overwriting (in which case you exit the loop) or
trying to enter an unused name; if not, exit the loop.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jim Thomlinson" wrote in message
...
Why not just use the SaveAs dialog then?

Application.Dialogs(xlDialogSaveAs).Show "MyFile.xls"
--
HTH...

Jim Thomlinson


"simonc" wrote:

GetSaveAsFileName only returns the path where you want to write the file,
without any checking or actual saving. How do you code a check that if
this
file already exists it asks if you want to overwrite it or not, and, if
you
decide not, would keep the GetSaveAsFileName dialog open so you can type
in a
new file name? (ie, exactly the behaviour you get when you use SaveAs in
Microsoft Excel).

Grateful for any help.