VBA Msgbox - No default button

I would like to know if it is possible to show Msgbox in VBA (Excel 2007), without any button installed by default? I have a yes \ no button and I don’t want the user to press return or space and accidentally launch the default button.

Does anyone know if this is possible so that not a single button in my form is set by default, forcing the user to click yes or no?

If MsgBox("Message goes here", vbYesNo + vbQuestion ) = vbYes Then
    'Something
Else
    'Else
End If
+4
source share
3 answers

No, this is impossible, unfortunately.

A ( ) UserForm. , , , .

+2

( UserForm trapping Enter Space ..)

  • ,
  • ,

Dim lngMsg As Long
Do
lngMsg = MsgBox("Message goes here (Yes or No)", vbQuestion + vbYesNoCancel + vbDefaultButton3)
Loop While lngMsg = vbCancel
If lngMsg = vbYes Then
' route a
Else
' route b
End If
+6
If MsgBox("Message goes here", vbYesNo + vbQuestion **+ vbDefaultButton2**) = vbYes Then
    'Something
Else
    'Else
End If
-1
source

Source: https://habr.com/ru/post/1535747/


All Articles