+ Reply to Thread
Results 1 to 4 of 4

ActiveX change event firing in sheet destructor when object already out of scope

  1. #1
    Registered User
    Join Date
    10-08-2014
    Location
    Delft
    MS-Off Ver
    2010
    Posts
    2

    Angry ActiveX change event firing in sheet destructor when object already out of scope

    Hi all,

    I have several ActiveX combo-boxes on a sheet. Each one has code for the change event, so an update to the first automatically fills the next boxes with appropriate values. So far, so good. It works as intended.

    But when I close the workbook a change event gets fired. By the time it is processed however, the ActiveX objects the event should act on do no longer exist. So I get a compilation error on statements like
    Please Login or Register  to view this content.
    . Because it is a compilation error, I cannot trap it with
    Please Login or Register  to view this content.
    .

    I tried setting a global flag in
    Please Login or Register  to view this content.
    and various other places, but it seems the event is passed the value of that flag as it was when triggered, which is before
    Please Login or Register  to view this content.
    . By the time it actually starts processing the event my Debug.Print statement says we passed
    Please Login or Register  to view this content.
    and the flag is set. But the check in the change event (
    Please Login or Register  to view this content.
    ) says not. So the event continues to the routine doing the actual work, and raises an error on the
    Please Login or Register  to view this content.
    code.

    Any suggestions are welcome, this is driving me nuts.

    Yours,

    André

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: ActiveX change event firing in sheet destructor when object already out of scope

    First thoughts:
    1. Don't use activex controls on worksheets - they behave oddly.
    2. If you do, don't refer to them as members of the worksheet, use a reference like:
    Please Login or Register  to view this content.
    which should only ever produce a run-time error.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    10-08-2014
    Location
    Delft
    MS-Off Ver
    2010
    Posts
    2

    Re: ActiveX change event firing in sheet destructor when object already out of scope

    Romperstomper,

    I have to use the ActiveX version, for they expose some properties that the build in combobox lacks. But your solution works! Thanx a million.

    André

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: ActiveX change event firing in sheet destructor when object already out of scope

    Glad to help. Please don't forget to mark the thread solved using the Thread Tools link at the top of the page.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. ActiveX ComboBox Firing on change in Cells
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 07:43 AM
  2. How to prevent SelectionChange event firing before Change event?
    By franklyn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 05:17 AM
  3. Selection Change Event Not Firing
    By SDruley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2011, 06:59 AM
  4. Workshet Change Event for dynamic range starting but not firing for target cells
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2010, 08:56 PM
  5. Worksheet Selection Change event not firing??
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2006, 10:29 AM

Tags for this Thread

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