PDA

View Full Version : How to avoid displaying a warning box on save?



RonMcK
08-21-2008, 08:49 AM
What do I add to the following line of code to coax VBA into overwriting the existing file with the new changes? Can I do this without resorting to toggling Alerts off and then back on after the save? Accompanying is the warning msg that I would rather my users not see.

Workbooks(2).Close SaveChanges:=True, FileName:=myFileName
Thanks,

marshybid
08-21-2008, 08:55 AM
Hi RonMck,

I add the following just before my save statements


On Error Resume Next
Kill myFileName
On Error GoTo 0


Workbooks(2).Close SaveChanges:=True, FileName:=myFileName



This works fine for me

Marshybid

RonMcK
08-21-2008, 09:00 AM
marshybid,

Hmmm? Interesting. I'd rather not delete my previous edition of the file so I can recover if this Save fails. I suppose I could turn on saving backup copies as the default for the files in this set.

Anyone else?

Thanks,

marshybid
08-21-2008, 09:08 AM
Have you thought about date or time stamping the filename (that way you maintain version control over the document);


DateF = Format(Now, "yy - mm - dd - hhmm")
myFileName = "Your Filepath Here + Filename_" & DateF & ".xls"
On Error Resume Next
Kill myFileName
On Error GoTo 0

Workbooks(2).Close SaveChanges:=True, FileName:=myFileName


All of my VB saved documents have a date/time stamp built into the filename so that I can always revert to previous versions if needed.

Don't know if this will help you, but I hope so.

Marshybid

RonMcK
08-21-2008, 09:14 AM
marshybid,

This may be the better solution. Aside from when I'm first debugging a program, there will only be two copies of any given file, the source and the updated version. Let me work with this a wee bit, it would be better for my old file to have the date/time stamp and the new one to have just the filename. It's the new file that I need to pass to associates for them to work with and on.

Thanks!

Bob Phillips
08-21-2008, 09:40 AM
Doesn't



Application.DisplayAlerts = False


do it?

Edit:

Just noticed you said you didn't want to do that, why I have no idea, but it invalidates my response regardless.