View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Answering Message boxes

Reading carefully what isbjornen wrote, I believe the line he wants to use is:
ThisWorkbook.Saved = True

This prevents the Excel software from automatically asking if you want to
save. To incorporate it into your code in response to a MsgBox you would
most likely have to use an If statement like:
If MsgBoxResponse = vbNo Then
ThisWorkbook.Saved = True
End If

Maybe we are confusing Message Box and Dialog Box?

"isbjornen" wrote:

Thanks, but I'm trying to avoid having a default Windows messagebox popping
up and pausing the macro. In the example below, I don't want to save before
exiting the program, i.e. I want the answer to be [No] without clicking.

"ChadF" wrote:


Hello,

You might want to consider this approach:

Dim myAnswer as String

myAnswer = MsgBox "Do you want to Save", vbYesNo

if myAnswer = vbYes then
.... 'do something
else
... ' do something else ...
end if

There are several options you can do with MsgBox.

Hope this helps,
Chad


"isbjornen" wrote:

Hello,

I have a question on how to answer message boxes programmatically.
For example: Answering [No] when closing a file and the message box prompts
me to save.
I've programmed in Lotus before and I used this command:
AnswerMsgBox (Value)

The command had to be entered on the line preceding the message box
AnswerMsgBox No
Application.Quit
In this example the program does not prompt to save before closing.

Is there a similar command in Excel?

Thanx!