Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overwrite file on save 1

Status
Not open for further replies.

FoxProProgrammer

Programmer
Apr 26, 2002
967
US
Hi folks,

I am working on some Excel macros that save a file. If the file already exists, Excel displays a message that asks me if I want to overwrite the file. I always want to overwrite the file. Is there a way to save the file without this message being displayed? I tried setting the warnings off, but that chooses the default, which is No, don't overwrite the file. I was thinking that there might be an option when you save the file to set the overwrite off.

Thanks for your help.



dz
dzaccess@yahoo.com
 
This is really a VBA question. See my post in thread707-575341

 
Thanks for your reply. Here is the problem with Application.DisplayAlerts = False

According to Excel Help for DisplayAlerts:

The default value is True. Set this property to False if you don't want to be disturbed by prompts and alert messages while a macro is running; any time a message requires a response, Microsoft Excel chooses the default response.

The default response is No. I want to overwrite the file, so would have to select Yes.



dz
dzaccess@yahoo.com
 

Did you actually try it? You really shouldn't believe everything you read, even from Micro$oft.

 
Yes it does work. Sorry, I had another problem that was keeping it from working, and I thought it was due to what I read in the Help file. Thanks for your help.

Regards,


dz
dzaccess@yahoo.com
 
Thank you, Zathras!!!
Your suggestion for setting Application.DisplayAlerts = False worked like a charm. I am using Access 97 and all I wanted to do was open an existing spreadsheet (in Excel 2000), write to some cells, save it and return to Access without any user intervention.

To make it work, after opening it and writing to the cells, I use this code...

Dim appExcel As Object

... code to open existing spreadsheet here...
... write to cells here ...

appExcel.Application.DisplayAlerts = False
appExcel.Application.Save
appExcel.Application.DisplayAlerts = True
appExcel.Application.Quit

Set appExcel = Nothing

I don't know what it is about Help files and a lot of books about Access, but often, the examples just do not work as described.

flize
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top