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.
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.
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]