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!

Can I overwrite with no prompt?

Status
Not open for further replies.

vbpadawan

Programmer
Oct 8, 2002
28
US
Is there a way for me to save a file and overwrite an existing file without a prompt to overwrite?

I am creating an excel file and when I saveAs, I do not want it to prompt to overwrite but I do want it to overwrite the existing file.

xlSheet.SaveAs "c:\FileName.xls"

Thanks.
 
My feeling here is that the is no easy built in function that allows for that. The save as will allow you to specify a filename, but if it exists it seems to always prompts you to overwrite.


You will probably need to use something like the filesystem object delete the target file first, if it exists and then invoke the excel saveas method.

HTH


Rob
 
Set the DisplayAlerts property of Excel Application object to False before saving the sheet.
___
xlApp.DisplayAlerts = False
xlSheet.SaveAs "c:\FileName.xls"
 
Set DisplayAlerts to false:

appXL.DisplayAlerts = False

where appXL is the name of your application object


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top