Like this:Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)If CloseMode = vbFormControlMenu ThenCancel = TrueMsgBox "You can't close the dialog like this!"End IfEnd Sub