Preventing "Do you want to ov erwrite" screen on saveas

J

Jonathan Blitz

I have code from VB that does SAVEAS for an Excel file in order to add a
password.
Problem is that when I run it the program asked for comfirmation from the
user because I am overwriting the same file.
Is there any way to prevent this?

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 
G

Gord Dibben

Jonathan

Wrap the DisplayAlerts = False and True around your code.

Sample code.........

Sub BUandSave2()
'Saves the current file to a backup folder and the default folder
'Note that any backup is overwritten
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs FileName:="E:\GordStuff\Backup\" & _
ActiveWorkbook.Name
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top