LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Worksheet change event not firing

Yeah, thisapp and thiswb.application point to the same thing.
I tried the doEvents, but no luck. Unfortunately I can't send you the
code.
I don't know much about the WITHEVENTS APPLICATION object, but it
sounds like that is really what I should be using. What are some good
resources to find out more about this?
Thanks again for your help. This one really has me stumped....


keepITcool wrote in message . ..
I can follow your explanation but can't pinpoint
the cause.

What surprises me is you dont seem to be using
a WITHEVENTS APPLICATION object in either of your
"containers"?

That way you can clear all the event code for the "XLS",
since you can simply monitor all events within
the running instance from 1 location.

What I do see is:
since I cant tell the scope of certain veriable you use..
e.g. are you sure the ThisApp application object variable
points to the same application instance as ThisWb.Application?

.. apparently you've checked this...

as a last resort...
include a DoEvents to give all the callbacks time
to be processed.

Else

If possible mail me the XLS, XLA and the DLL's VBA project
I'm willing to help you debug or suggest "informed" alternatives.
but like this it's just guessing.


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Wexler) wrote:

This is the setup:
I have a regular excel workbook, and all its event handlers just call
a sub in an excel add-in. The excel add-in then makes a call to an
ActiveX DLL. The DLL has a global variable reference to the original
workbook. So, the user clicks on a cell, which fires the
worksheetselection_change event in the workbook, which calls a sub in
the add-in, which calls a sub in the DLL. This sub fires a form which
resides in the DLL. The user can type a value in a text box, click
OK, and the code in the OK_click event of the form in the DLL writes
this value directly to the original workbook.
I have been using this same setup for everything, I have 50 or so
forms which all work, and all generate events in the original workbook
in situations like this one. But for some reason in this particular
instance, it doesn't. The DLL has a handle on the right workbook, and
right sheet, because the value is written to the right place.
Here is the actual code:

In the original workbook:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run
"'CO2005AddIn.xla'!EstimateWSEvents.PTWorksheet_Se lectionChange",
Target
End Sub

In the Add-In's EstimateWSEvents module:
Sub PTWorksheet_SelectionChange(ByVal Target As Range)
UDAESTDLL.PTWorksheetSelectionChange Target
End Sub

In the DLL:
Public Sub PTWorksheetSelectionChange(ByVal Target As Range)
'some irrelevant code...
CategoryInfo.Show vbModal
end Sub

then the form comes up, the user types in the text box, and clicks OK:
In the OK_Click event handler of the CategoryInfo form:
Private Sub OK_Click()
ThisApp.ScreenUpdating = False

MsgBox "changing category name"

MsgBox ThisApp.EnableEvents 'this always comes up "True"

ThisApp.EnableEvents = True 'I set it just to make extra sure

'this line works
ThisWB.ActiveSheet.Range("D" & ThisApp.ActiveCell.row) =
NameTextBox.Text

'but this line is executed immediately after the previous one (no
event generated)
MsgBox "Changed name in workbook. Now back in form."

Unload Me
End Sub

'Now, writing NameTextBox.Text should have made the execution go
straight to the worksheetchange event in the original workbook:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.Run
"'CO2005AddIn.xla'!EstimateWSEvents.PTWorksheet_Ch ange",
Target
End Sub

'which would call the add-in:
In the Add-In's EstimateWSEvents module:
Sub PTWorksheet_Change(ByVal Target As Range)
UDAESTDLL.PTWorksheetChange Target
End Sub

'which would call the DLL and take an appropriate action.
But the code skips generating the event and just stays in the form.

I hope this clears things up for you, cool.
Thanks again for your help.


keepITcool wrote in message
. ..
What did the dialog say?

Be aware your testing the Activesheet of THISWORKBOOK.
(that's the WB in which the form resides.)

That could very well be different from the Activesheet in the
Activeworkbook


Else just zip and email to addr below.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage:
http://members.chello.nl/keepitcool


(Wexler) wrote:

cool,
Thanks for your suggestion. I put a breakpoint in the
worksheetchange event handler sub, and when I type in the cell
manually, it stops at the breakpoint. When I use the form, it
never hits the breakpoint. The same sheet is always active when I
use the form, and the value is written to the sheet, but no
event.... Any other ideas?

keepITcool wrote in message
. ..
put


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet Change Event Tony S.[_2_] Excel Discussion (Misc queries) 11 February 18th 09 01:04 AM
Workbook open event not firing (both 2000 and XP) Greg Lesnie Excel Programming 2 October 17th 04 10:31 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Workbook.Open Event Procedure not firing Gordon Rodman Excel Programming 1 October 17th 03 05:03 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 06:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"