PC Review


Reply
Thread Tools Rate Thread

Choosing no when asked to overwrite an existing file?

 
 
carl
Guest
Posts: n/a
 
      5th Jan 2008
I'm trying to write a piece of code that tells the macro to automatically
choose "no" when ever the following message comes up while a macro is being
run:

"The file ... already exists. Do you want to replace the existing file?"

And then to give a message box saying that you can't overwrite an existing
file and end the sub.

Is it an IF statement?

The reason this message will come up while the macro is running is because
the person has chosen the wrong date from the drop down box. It won't come
up if they choose the right date because the file won't exist.
 
Reply With Quote
 
 
 
 
GTVT06
Guest
Posts: n/a
 
      5th Jan 2008
On Jan 5, 10:36*am, carl <c...@discussions.microsoft.com> wrote:
> I'm trying to write a piece of code that tells the macro to automatically
> choose "no" when ever the following message comes up while a macro is being
> run:
>
> "The file ... already exists. *Do you want to replace the existing file?"
>
> And then to give a message box saying that you can't overwrite an existing
> file and end the sub.
>
> Is it an IF statement?
>
> The reason this message will come up while the macro is running is because
> the person has chosen the wrong date from the drop down box. *It won't come
> up if they choose the right date because the file won't exist.


If Dir("C:\Enter your save as criteria here\Book.xls") <> "" Then
MsgBox "You can't overwrite an existing file"
Exit Sub
Else
ActiveWorkbook.SaveAs Filename:= _
"C:\Enter your save as criteria here\Book.xls",
FileFormat:=xlNormal
End If
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vb2005 - how to overwrite an existing file? spowel4 Microsoft VB .NET 2 15th Mar 2007 09:17 PM
Remove Macros before send? & Runtime error if choosing not to overwrite file? nbaj2k Microsoft Excel Programming 17 11th Aug 2006 11:42 AM
Overwrite existing file without prompt =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 0 17th Sep 2004 01:21 PM
Re: Overwrite an existing file Bob Umlas Microsoft Excel Misc 0 2nd Sep 2004 03:49 PM
Re: Overwrite an existing file Harald Staff Microsoft Excel Misc 0 2nd Sep 2004 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 PM.