Code automatic response to message

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone.

I have a macro that includes an e-mail button to e-mail the active workbook as an attachment. Because the recipients add information to it, I included in the e-mailing code the line ActiveWorkbook.Save.

When executed for the first time, this line causes Excel to display the message
"A file named (filename) already exists in this location. Do you want to replace it?"
to which I'd like to code an automatic response of Yes. Better yet, if there is a way to elilminate the message from displaying but allowing the save operation to complete it would be great.

Suggestions please? Thank you all.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can add Application.DisplayAlerts = False to the beginning of the code. Just make sure to set it to True at the end.

HTH,
 
Upvote 0
Thanks, Smitty... But I need a clarification: the possible responses to the alert I described were Yes, NO and Cancel. Does suppressing the Alert make the saving operation in my macro to assume that the response is Yes?
 
Upvote 0
Yup.

Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True


Will save the wb without any alerts.

You can also use ActiveWorkbook.Close True to close and save changes.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top