R
Rick Labs
I'm trying to track down any info on when VBA code gets halted and/or
ActiveX events are dropped. (See Richard King's comments below).
It’s important that the Excel hosted VBA code I'm working on responds to
EVERY event fired by the ActiveX control. It's O.K. to have them back up a
bit but I must be sure that EVERY event raised in the ActiveX control
gets "sunk" by Excel VBA code.
To that end I made a testing sample spreadsheet located at:
http://clbcm.com/events example.xls
You have to save the file and open it in Excel. It doesn't run correctly
from the IE browser.
The spreadsheet has an internal timer that fires an event every second.
Each of three event sinks (located in three user forms,) “listen†for those
events, and when received, they write a 1 to the spreadsheet, illustrating
they indeed got it.
All you have to do is edit a cell while the program is running to see that
events are dropped, gone forever. However, in the majority cases of moving
windows around, resizing, etc, events are not dropped, they are just cued
back which works fine for me.
If anyone has ANY experience with this please describe what you encountered
and/or how you insured all events were processed and not dropped. Any code
examples would also be most appreciated.
Thanks.
Rick
-------------------------------------------------------------
Richard King’s Conclusions:
1. Events are NOT dropped as a result of Excel executing VBA. My
spreadsheet was processing so much VBA that at the end of the test, the
Excel events were being logged more than 4 minutes behind the VB events,
but not one was dropped.
2. Events are NOT missed as a result of Excel recalculating the
spreadsheet.
3. However, events ARE dropped whenever you type into a cell or the formula
bar. From the time you press the first key to the time you press enter,
Excel simply ignores events from all sources. This is not a problem with
the TWS ActiveX control, it's a problem with Excel itself.
4. Also, events ARE dropped when Excel displays a message box or a modal
dialogue box (such as File > Open).
Recommendations
---------------
I believe you CAN use the ActiveX control successfully with Excel 2000, but
only subject to some serious caveats:
- any required user input must be via controls such as text boxes, check
boxes, combo boxes etc (typing in these does not cause events to be
dropped)
- the user must not type into any Excel cell (unfortunately locking all the
cells does not help, because an attempt to type into a locked cell causes
Excel to display a message box, which itself causes events to be dropped!)
- the user must not use any menu options that display dialogue boxes (such
as File > Open or Tools > Data Analysis)
- VBA code must not use the msgBox function
ActiveX events are dropped. (See Richard King's comments below).
It’s important that the Excel hosted VBA code I'm working on responds to
EVERY event fired by the ActiveX control. It's O.K. to have them back up a
bit but I must be sure that EVERY event raised in the ActiveX control
gets "sunk" by Excel VBA code.
To that end I made a testing sample spreadsheet located at:
http://clbcm.com/events example.xls
You have to save the file and open it in Excel. It doesn't run correctly
from the IE browser.
The spreadsheet has an internal timer that fires an event every second.
Each of three event sinks (located in three user forms,) “listen†for those
events, and when received, they write a 1 to the spreadsheet, illustrating
they indeed got it.
All you have to do is edit a cell while the program is running to see that
events are dropped, gone forever. However, in the majority cases of moving
windows around, resizing, etc, events are not dropped, they are just cued
back which works fine for me.
If anyone has ANY experience with this please describe what you encountered
and/or how you insured all events were processed and not dropped. Any code
examples would also be most appreciated.
Thanks.
Rick
-------------------------------------------------------------
Richard King’s Conclusions:
1. Events are NOT dropped as a result of Excel executing VBA. My
spreadsheet was processing so much VBA that at the end of the test, the
Excel events were being logged more than 4 minutes behind the VB events,
but not one was dropped.
2. Events are NOT missed as a result of Excel recalculating the
spreadsheet.
3. However, events ARE dropped whenever you type into a cell or the formula
bar. From the time you press the first key to the time you press enter,
Excel simply ignores events from all sources. This is not a problem with
the TWS ActiveX control, it's a problem with Excel itself.
4. Also, events ARE dropped when Excel displays a message box or a modal
dialogue box (such as File > Open).
Recommendations
---------------
I believe you CAN use the ActiveX control successfully with Excel 2000, but
only subject to some serious caveats:
- any required user input must be via controls such as text boxes, check
boxes, combo boxes etc (typing in these does not cause events to be
dropped)
- the user must not type into any Excel cell (unfortunately locking all the
cells does not help, because an attempt to type into a locked cell causes
Excel to display a message box, which itself causes events to be dropped!)
- the user must not use any menu options that display dialogue boxes (such
as File > Open or Tools > Data Analysis)
- VBA code must not use the msgBox function