Consulting

Results 1 to 7 of 7

Thread: Solved: Hiding the "X" or close button on user form

  1. #1
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location

    Solved: Hiding the "X" or close button on user form

    Is it posible to hide "X" or close button on a user form? if not could it be disabled ?

    Thanks For Any Help

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,284
    Location
    They can both be done. Will give you the disable thing. To hide the caption bar, you'll need some api calls. Have to browse to my collection if you really want this. For now, this one will give a warning when pressing the x on a form.[VBA]Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then
    Cancel = True
    MsgBox "The X is disabled, please use the Close Command Button.", vbCritical
    End If
    End Sub[/VBA]
    Charlize

  3. #3
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    220
    Location
    Here is some code to disable the close button on an excel userform with downloadable excel example.

    http://www.vbforums.com/showthread.php?t=363931

  4. #4
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    THANKS FOR THE CODE CHARLISE AND CARL A ,if you do find time to write the codeCharlise ,I would liketo hide the caption bar

  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,284
    Location
    Quote Originally Posted by BENSON
    THANKS FOR THE CODE CHARLISE AND CARL A ,if you do find time to write the codeCharlise ,I would liketo hide the caption bar
    As requested ...

  6. #6
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Quote Originally Posted by Charlize
    [vba]Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then
    Cancel = True
    MsgBox "The X is disabled, please use the Close Command Button.", vbCritical
    End If
    End Sub[/vba]
    The user clicked on the close button to close the form, right? Instead of showing an unnecessary message and making the user make an unnecessary mouse click, simply let the close button (which I'll assume is named "btnClose") close the form:

    [vba]Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then
    Cancel = True
    btnClose_Click
    End If
    End Sub
    [/vba]
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  7. #7
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,284
    Location
    Quote Originally Posted by JonPeltier
    The user clicked on the close button to close the form, right? Instead of showing an unnecessary message and making the user make an unnecessary mouse click, simply let the close button (which I'll assume is named "btnClose") close the form.
    Thanks for the idea.

    Charlize

Posting Permissions

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