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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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,224,548
Messages
6,179,445
Members
452,915
Latest member
hannnahheileen

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