PDA

View Full Version : Msgbox Disabling



pico
12-04-2006, 12:22 PM
I have a msgbox pop up in my macro. I need a feature in there so that if the user thinks its not necessary, disable the msgbox for the next time the macro opens. For example a checkbox in the messagebox that says if you enable it the message box will not appear the next time the macro is opened. How can i go about coding this?

makako
12-04-2006, 03:18 PM
Usually one could go controling this in a "xlveryhidden" worksheet but another option is to change your code in code. search for and auto-delete code or selfdelete procedure i recently found and there youll find some ideas

lucas
12-04-2006, 07:37 PM
how do you put a checkbox on a messagebox.....

lucas
12-04-2006, 08:06 PM
This might work but you would have to have two macro's exactly alike except one doesn't have the messagebox code.
Sub a()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Click Yes to continue, If you don't wish" & vbLf & "to see this message again" _
& Chr(13) & "then click no" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton1 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
GoTo Continue ' Perform some action.
Else ' User chose No.
Call subB ' Perform some action.
End If
End
Continue:
MsgBox "This is where" & vbLf & "the macro continues" _
& Chr(13) & "If they click yes"
End Sub
Sub subB()
MsgBox "This sub is just like sub a" & vbLf & "except it would not have " _
& Chr(13) & "a call to the messagebox"
End Sub
I hope someone has a better idea than this....

malik641
12-04-2006, 10:21 PM
Isn't there a KB that deals with one time macros? I can't find it.


An easy way out is like makako said with the xlSheetVeryHidden with the value (boolean) that says to show the message box or not. And I would probably make my own message box if I were you if you want a checkbox in it.

I guess check this example out. The sheet "SheetVeryHidden" is not hidden just to show you how it works.

HTH

lucas
12-04-2006, 11:55 PM
Works great Joseph....

Charlize
12-05-2006, 03:00 AM
You could use a documentvariable named ShowIntroMessage. When you click no put a 1 in it. The macro with the messagebox has a check on ShowIntroMessage. If its different then 1, show messagebox else don't.

Charlize