Consulting

Results 1 to 7 of 7

Thread: Msgbox Disabling

  1. #1
    VBAX Contributor
    Joined
    Nov 2006
    Posts
    107
    Location

    Msgbox Disabling

    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?

  2. #2
    VBAX Contributor
    Joined
    Aug 2006
    Posts
    120
    Location
    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

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    how do you put a checkbox on a messagebox.....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    This might work but you would have to have two macro's exactly alike except one doesn't have the messagebox code.
    [VBA]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[/VBA]
    I hope someone has a better idea than this....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Works great Joseph....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •