PDA

View Full Version : Solved: Excel confirmation messages



tkaplan
11-23-2005, 08:34 AM
I have a whole big macro that i wrote that part of it copies cells and pastes to another workbook, then it closes the first workbook.
when i run the macro, the message comes up asking me if i want to save the data in the clipboard before it closes the file.

How can i eliminate that? i do not want the data saved to the clipboard and i dont want the user having that option.

Also, when i do a save as using a macro, it asks me if i want to replace the existing file. I want this to always be yes as well, without asking the user.

Any suggestions of what line of code i can add to take care of this?

Zack Barresse
11-23-2005, 08:40 AM
This will supress all messages from Excel..

Application.DisplayAlerts = False
'..
'.. code
'..
Application.DisplayAlerts = True

If you get the 'save over' message box, it will automatically save over any earlier file. There are functions you can write to check if the file exists.

tkaplan
11-23-2005, 08:45 AM
this is perfect. i know that the file exists but i want it overwritten so that's exactly what i needed.
do i put this in the genera statements section, like where i put option explicit, etc. or after the line sub...() and before end sub?

Zack Barresse
11-23-2005, 08:47 AM
Sorry, it must be enclosed inside your routine, so Sub(), ..=False, code, ..=True, End Sub.

tkaplan
11-23-2005, 08:49 AM
Thank you.
Works perfectly:)