+ Reply to Thread
Results 1 to 3 of 3

Can you disable button on a UserForm?

Hybrid View

j_Southern Can you disable button on a... 11-21-2012, 08:51 AM
Kyle123 Re: Can you disable button on... 11-21-2012, 08:53 AM
Andy Pope Re: Can you disable button on... 11-21-2012, 08:55 AM
  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Can you disable button on a UserForm?

    I have a userform that I want to be closed/hidden by using a button that ensures that files are copied as the form is hidden. My problem is that the form also has a close cross and i have not been able to find a way to disable this. Alternatively can I associate the code of the command button with hitting the cross?
    Hope somebody can help
    regards
    John

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Can you disable button on a UserForm?

    This will disable the cross on the userform:
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Cancel = 1
    MsgBox "Please use the buttons on the Form to close this window", vbExclamation + vbDefaultButton1
    End Sub

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Can you disable button on a UserForm?

    There is API code to remove the button.
    See FormFun example file.
    http://www.oaltd.co.uk/Excel/Default.htm

    or you could catch the event
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    
        If CloseMode = 0 Then
            MsgBox "Please use Close Button Provided"
            Cancel = True
        End If
            
    End Sub
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1