+ Reply to Thread
Results 1 to 5 of 5

Close Button Error

  1. #1
    Allen Geddes
    Guest

    Close Button Error

    Hello,

    I've created a UserForm, but seem to be having problems with the
    automatically inserted red x close button in the upper right corner of the
    UserForm.

    When I try and exit my UserForm by using that red X, I get the following
    error message:

    Run-time error '91':

    Object variable or With Block variable not set

    Do I need to put in a piece of code to activate the red X button?

    something like:

    Private sub UserForm_Terminate()

    unload me

    End Sub


    Thank you in advance for your help!!

  2. #2
    JNW
    Guest

    RE: Close Button Error

    You likely have a userform event that triggers when the form closes that is
    causing the error. The [x] should work on its own. When you get the error
    message, click debug then see which line of a particular sub is causing the
    error. If you can post the code for that sub, we can help you out.

    "Allen Geddes" wrote:

    > Hello,
    >
    > I've created a UserForm, but seem to be having problems with the
    > automatically inserted red x close button in the upper right corner of the
    > UserForm.
    >
    > When I try and exit my UserForm by using that red X, I get the following
    > error message:
    >
    > Run-time error '91':
    >
    > Object variable or With Block variable not set
    >
    > Do I need to put in a piece of code to activate the red X button?
    >
    > something like:
    >
    > Private sub UserForm_Terminate()
    >
    > unload me
    >
    > End Sub
    >
    >
    > Thank you in advance for your help!!


  3. #3
    Allen Geddes
    Guest

    RE: Close Button Error

    Unfortunately, "Debug" doesn't come up for this particular error. The only
    options are "OK" and "Help".

    -Allen



    "JNW" wrote:

    > You likely have a userform event that triggers when the form closes that is
    > causing the error. The [x] should work on its own. When you get the error
    > message, click debug then see which line of a particular sub is causing the
    > error. If you can post the code for that sub, we can help you out.
    >
    > "Allen Geddes" wrote:
    >
    > > Hello,
    > >
    > > I've created a UserForm, but seem to be having problems with the
    > > automatically inserted red x close button in the upper right corner of the
    > > UserForm.
    > >
    > > When I try and exit my UserForm by using that red X, I get the following
    > > error message:
    > >
    > > Run-time error '91':
    > >
    > > Object variable or With Block variable not set
    > >
    > > Do I need to put in a piece of code to activate the red X button?
    > >
    > > something like:
    > >
    > > Private sub UserForm_Terminate()
    > >
    > > unload me
    > >
    > > End Sub
    > >
    > >
    > > Thank you in advance for your help!!


  4. #4
    JNW
    Guest

    RE: Close Button Error

    hmm...

    Try looking at the code for the userform on your own. Check to see if you
    have any of the following userform events:
    Deactivate
    QueryClose
    Terminate

    never a bad idea to post any code you have on the Userform so that we can
    take a look at what might be causing the problem

    "Allen Geddes" wrote:

    > Unfortunately, "Debug" doesn't come up for this particular error. The only
    > options are "OK" and "Help".
    >
    > -Allen
    >
    >
    >
    > "JNW" wrote:
    >
    > > You likely have a userform event that triggers when the form closes that is
    > > causing the error. The [x] should work on its own. When you get the error
    > > message, click debug then see which line of a particular sub is causing the
    > > error. If you can post the code for that sub, we can help you out.
    > >
    > > "Allen Geddes" wrote:
    > >
    > > > Hello,
    > > >
    > > > I've created a UserForm, but seem to be having problems with the
    > > > automatically inserted red x close button in the upper right corner of the
    > > > UserForm.
    > > >
    > > > When I try and exit my UserForm by using that red X, I get the following
    > > > error message:
    > > >
    > > > Run-time error '91':
    > > >
    > > > Object variable or With Block variable not set
    > > >
    > > > Do I need to put in a piece of code to activate the red X button?
    > > >
    > > > something like:
    > > >
    > > > Private sub UserForm_Terminate()
    > > >
    > > > unload me
    > > >
    > > > End Sub
    > > >
    > > >
    > > > Thank you in advance for your help!!


  5. #5
    Allen Geddes
    Guest

    RE: Close Button Error

    Problem Solved.

    Private Sub UserForm1_Initialize()

    Application.Visible = False
    UserForm1.Show '<==== There was my problem...

    End Sub

    You don't have to tell it to show the userform, it automatically shows,
    because I call it in my Workbook_Open() line of code. So, everytime I tried
    closing the box, it would go against the userform1.show... causing an error.
    Good to know! Thanks!

    -Allen




    "Allen Geddes" wrote:

    > Unfortunately, "Debug" doesn't come up for this particular error. The only
    > options are "OK" and "Help".
    >
    > -Allen
    >
    >
    >
    > "JNW" wrote:
    >
    > > You likely have a userform event that triggers when the form closes that is
    > > causing the error. The [x] should work on its own. When you get the error
    > > message, click debug then see which line of a particular sub is causing the
    > > error. If you can post the code for that sub, we can help you out.
    > >
    > > "Allen Geddes" wrote:
    > >
    > > > Hello,
    > > >
    > > > I've created a UserForm, but seem to be having problems with the
    > > > automatically inserted red x close button in the upper right corner of the
    > > > UserForm.
    > > >
    > > > When I try and exit my UserForm by using that red X, I get the following
    > > > error message:
    > > >
    > > > Run-time error '91':
    > > >
    > > > Object variable or With Block variable not set
    > > >
    > > > Do I need to put in a piece of code to activate the red X button?
    > > >
    > > > something like:
    > > >
    > > > Private sub UserForm_Terminate()
    > > >
    > > > unload me
    > > >
    > > > End Sub
    > > >
    > > >
    > > > Thank you in advance for your help!!


+ 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