Consulting

Results 1 to 2 of 2

Thread: Solved: Custom Message Box

  1. #1
    VBAX Regular
    Joined
    May 2004
    Posts
    42
    Location

    Solved: Custom Message Box

    I am trying to create a custom message box similar to the VBYesNO. Instead of the buttons being Yes or No I would like them to be Preview or Print.

  2. #2
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    I think you'll have to create your own userform with labels and buttons just as you need them + add a function to evaluate what was clicked so you can call the whole thing just like an ordinary msgbox.

    I once did this with a YesNoAbort-Box which should allow the user to go back 1 step. Maybe you can change this example to fit your needs.

    This was the code from the form:

    [VBA]
    Private Sub cmd_Abbrechen_Click()
    Me.Tag = "Abbrechen"
    Me.Hide
    End Sub
    Private Sub cmd_Ja_Click()
    Me.Tag = "Ja"
    Me.Hide
    End Sub
    Private Sub cmd_Nein_Click()
    Me.Tag = "Nein"
    Me.Hide
    End Sub
    Private Sub cmd_Zur?ck_Click()
    Me.Tag = "Zur?ck"
    Me.Hide
    End Sub
    Private Sub UserForm_Activate()
    cmd_Ja.SetFocus
    End Sub
    [/VBA]

    And this was the calling sub:
    [VBA]
    Public Function YesNo(Formulartitel$, Fragetext$) As String
    With frm_YesNo
    .Caption = Formulartitel
    .lbl_Frage.Caption = Fragetext
    .Show
    YesNo = .Tag
    End With
    Unload frm_YesNo
    End Function
    [/VBA]

    To use it:
    [VBA] Dim answer as String
    answer = YesNo("A Question","Do you want that?")
    If answer = "Ja" then ....
    [/VBA]

Posting Permissions

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