Blocking X button in UserForm

Many times I’ve wrote applications, where top right X button had to be disabled. Code has been borrowed from Johna Walkenbach.

When user clicks UserForm “X” button then Msgbox appears. Code for Msgbox:

MsgBox "To close this window please click START lub CLOSE.", vbInformation, "ERRROR..."

Please notice that MsgBox says that in UserForm there are two more button such as START and CLOSE. These buttons have to be added to UserForm with code to close Userform this is Unload Me.

Following code has to pasted in UserForm area, in UserForm area where we want to block right top X button:

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
      MsgBox "To close this window please click START lub CLOSE.", vbInformation, "ERRROR..."
      Cancel = True
    End If
End Sub

95 thoughts on “Blocking X button in UserForm

  1. Rebuilded solution. UserForm_QueryClose working together with UserForm_Terminate

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    ' Disable UserForm "X"  button,
    
    If CloseMode = vbFormControlMenu Then
        If MsgBox("Are you really shut down app?", vbYesNo + vbQuestion, "CLOSE...") = vbYes Then
            Call UserForm_Terminate
        Else
            ' vbNO, nothing happened
            Cancel = True
        End If
    End If
    End Sub
    
  2. Pingback: qiuqiu99

  3. Pingback: mơ thấy anh em gặp nhau

  4. Pingback: Parrots for Sale

  5. Pingback: australian labradoodle puppies for sale

  6. Pingback: Keltecs

  7. Pingback: SSCN BKN 2021 Kabupaten Muna Barat

  8. Pingback: mơ rắn cắn đánh đề bao nhiêu

  9. Pingback: Best CVV Sites

  10. Pingback: sex dolls shop

  11. Pingback: 12ga Shotgun

  12. Pingback: nằm mơ thấy rắn hổ mang

  13. Pingback: mơ thấy gấu đánh con gì

  14. Pingback: mo thay an bap

  15. Pingback: satta king

  16. Pingback: dơi bay vào nhà tốt hay xấu

  17. Pingback: nam mo thay gay rang

  18. Pingback: mơ thấy thỏ trắng

  19. Pingback: tor search

  20. Pingback: pasarqq

  21. Pingback: Stiiizy flavors

  22. Pingback: mơ bị đòi nợ

  23. Pingback: giải mã giấc mơ gặp người yêu cũ

  24. Pingback: mơ mất xe đạp đánh con gì

  25. Pingback: panzer bp12

  26. Pingback: mơ thấy đi chùa lạy phật

  27. Pingback: bai cat te

  28. Pingback: choi game doi thuong tren may tinh

  29. Pingback: mơ thấy đứt tay chảy máu

  30. Pingback: mơ thấy quả bưởi đánh con gì

  31. Pingback: nằm mơ thấy đi chùa

  32. Pingback: mơ thấy chuối xanh

  33. Pingback: mơ rụng tóc đánh con gì

  34. Pingback: tangerine sign in

  35. Pingback: dumps cc

  36. Pingback: realcouchtuner.com

  37. Pingback: do you need a driving license to buy a car uk

  38. Pingback: ตู้แปลภาษา

  39. Pingback: นิยาย pdf

  40. Pingback: nam mo thay giet nguoi

  41. Pingback: mơ bị sét đánh

  42. Pingback: mơ thấy tàu hỏa

  43. Pingback: www.bilskrotgbg.se

  44. Pingback: mơ thấy lợn đẻ

  45. Pingback: mơ thấy nhà đánh con gì

  46. Pingback: nằm mơ thấy đầu người

  47. Pingback: rapid rewards promo code 2017

  48. Pingback: 토토사이트 추천

  49. Pingback: 메이저놀이터

  50. Pingback: cpnsaubs

  51. Pingback: how safe is viagra

  52. Pingback: welke landen is viagra vrij verkrijgbaar

  53. Pingback: how many mg of zithromax to cure chlamydia

  54. Pingback: cialis

  55. Pingback: viagra no prescription

  56. Pingback: comprar viagra online contrareembolso

  57. Pingback: federal resume writing service

  58. Pingback: research writing

  59. Pingback: write my essay for me online

  60. Pingback: help me write an apa essay

  61. Pingback: amoxicillin 75 mg

  62. Pingback: how much is furosemide 20mg

  63. Pingback: zithromax prescription cost

  64. Pingback: stromectol in canada

  65. Pingback: order ventolin from canada no prescription

  66. Pingback: acne medication doxycycline

  67. Pingback: prednisolone acetate ophthalmic

  68. Pingback: is clomid legal

  69. Pingback: priligy tablets walmart

  70. Pingback: diflucan iv dose

  71. Pingback: synthroid vs armour

  72. Pingback: propecia wikipedia

  73. Pingback: neurontin and fibromyalgia

  74. Pingback: contraindications of metformin

  75. Pingback: paxil for dogs

  76. Pingback: plaquenil allergic rash

  77. Pingback: safe buy cialis

  78. Pingback: cost of tadalafil without insurance

  79. Pingback: cialis walmart

  80. Pingback: original for sale

  81. Pingback: online payday loan dearborn heights

  82. Pingback: sildenafil citrate 20 mg how fast does it work

  83. Pingback: retin a from canadian pharmacy

  84. Pingback: stromectol

  85. Pingback: how to know who liked you on tinder

  86. Pingback: advance america cash advance coon rapids

  87. Pingback: cialis without a doctor prescription

  88. Pingback: buy 36 hour

  89. Pingback: buy 36 hour

  90. Pingback: dating chat line free trial

  91. Pingback: buy ativan fast shipping

  92. Pingback: best price for tadalafil 20 mg

  93. Pingback: fildena pills

  94. Pingback: super fildena 100

  95. Pingback: generic cialis at walmart

Leave a Reply

Your email address will not be published. Required fields are marked *