Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 361
Default Choosing no when asked to overwrite an existing file?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Choosing no when asked to overwrite an existing file?

On Jan 5, 10:36*am, carl 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename rather than overwrite existing file jnf40 Excel Programming 4 August 31st 07 05:40 AM
Create a new file, name it and overwrite an existing name without confimation Rob[_5_] Excel Programming 2 January 14th 07 01:31 PM
Remove Macros before send? & Runtime error if choosing not to overwrite file? nbaj2k[_30_] Excel Programming 17 August 11th 06 11:42 AM
Overwrite existing file without prompt Tom Ogilvy Excel Programming 0 September 17th 04 01:41 PM
Overwrite existing file without prompt Mark Excel Programming 0 September 17th 04 01:21 PM


All times are GMT +1. The time now is 01:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"