PDA

View Full Version : Pseudo Event not firing



gmaxey
12-21-2012, 04:16 PM
Regulars here may have been following the project initiated by
Brent Fraser last week to create a dynamic apprasal form:

http://www.vbaexpress.com/forum/showthread.php?t=44751

There was something not quite right about how Brent's pseudo CC event monitor was performing but I didn't have time to dig into it until today.

The event should fire 1) when the user clicks in the CC (because this changes the state) and 2) when the user toggles the state from checked to unchecked and back.

Brent's is doing 1) but not 2).

I've figured out that the reason Brent's isn't working correctly is because he has changed both the checked and unchecked symbols for his monitored checkboxes to Windings characters.

I've been sitting here surrounded by clumps of hair and bloody scalp for most of the afternoon and I just can't nail down why the thing will work with:

1. The default checked and uncheck box.
2. A Windding checked and the default unchecked box.
3. A dollar sign for checked or cent sign for unchecked boxes.

But it won't work with:
1. A pair of similiar Wingding characters for the check and uncheck boxes e.g., a empty box and the x-box, an empy circle and radio button circle, etc.

A file with the working and not working examples is available here:
https://dl.dropbox.com/u/64545773/Company%20Performance%20Appraisal.dotm

As best I can tell, both symbols (when not working) is being interpreted by the monitor as the same symbol e.g., AscW(symbol.checked) and AscW(symbol.unchecked) are both returning 40 which is a opening "(" so I guess the monitor simply can't determine what it is seeing and just pukes up 40.

Hoping that one of the really bright guys or gals haunting this site will take interest and school me on how to determine and distinquish one symbol character displayed in a CC from a different symbol character and detect a change between the two in the monitor procedure found in the document.

Thanks.

gmaxey
12-21-2012, 05:47 PM
After looking around the web some more, it appears that several others smarter than me have thrown in the towel on a VBA method for identifying a symbol in a document.

I decided to go back and revise the basic event monitor to trigger on checkbox state change when monitoring a checkbox and trigger on range change when monitoring other type controls. The code is a bit gnarly, but seems to work.

Functional example located here: https://dl.dropbox.com/u/64545773/Company%20Performance%20Appraisal%20%28with%20improved%20checkbox%20event%2 0monitor%29.dotm

Paul_Hossler
12-26-2012, 09:36 PM
Can you explain why you need all that monitoring and custom events?

I've only used the 'built in' CC events, but then again I've never done anything that looked that complicated


Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)

End Sub


Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)


Exit Sub


I've seen the same problems with trying to get the symbol, but since there's a .Checked property as well as .SetCheckedSymbol and .SetUncheckedSymbol, I've just pretended the problem doesn't exist :dunno

macropod
12-27-2012, 01:04 AM
Ahem:
Sub GetSymbol()
Dim SelFont, SelCharNum
With Selection
With Dialogs(wdDialogInsertSymbol)
SelFont = .Font
SelCharNum = .CharNum
End With
End With
MsgBox SelFont & vbTab & SelCharNum
End Sub

gmaxey
12-27-2012, 07:40 AM
Hi Paul,

With all that monitoring there is a pseudo "change" event. Actions happen when the state of the CC changes rather than relying on or requiring the user to make the change and "exit" the control.




Can you explain why you need all that monitoring and custom events?

I've only used the 'built in' CC events, but then again I've never done anything that looked that complicated


Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)

End Sub


Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)


Exit Sub


I've seen the same problems with trying to get the symbol, but since there's a .Checked property as well as .SetCheckedSymbol and .SetUncheckedSymbol, I've just pretended the problem doesn't exist :dunno

gmaxey
12-27-2012, 07:43 AM
Hi Paul,

Yes, you've shown me that before. I could be wrong, but I don't think I could use it for the issue decribed above since what I was monitoring may or may not be the text currently selected.

I think I've resolve the issue requiring the symbol by monitoring the CC state rather than range.

Thanks.


Ahem:
Sub GetSymbol()
Dim SelFont, SelCharNum
With Selection
With Dialogs(wdDialogInsertSymbol)
SelFont = .Font
SelCharNum = .CharNum
End With
End With
MsgBox SelFont & vbTab & SelCharNum
End Sub

Paul_Hossler
12-27-2012, 09:21 AM
Actions happen when the state of the CC changes rather than relying on or requiring the user to make the change and "exit" the control.


So that if 'something' other that the user changes the CC, the pseudo-change event for the CC fires?

Much more than I'll ever do, but do you have an example?

Thanks

Paul

gmaxey
12-27-2012, 09:39 AM
Paul,

A file with working examples is available here:
https://dl.dropbox.com/u/64545773/Company%20Performance%20Appraisal%20%28with%20improved%20checkbox%20event%2 0monitor%29.dotm

When the user changes the state of the checkbox things happen.

Paul_Hossler
12-27-2012, 04:14 PM
Greg -- I saw the example earlier, but I wasn't exactly sure what to look for

I'll try to trace my way through it again, but this is grad level Word stuff

Paul

gmaxey
12-27-2012, 04:25 PM
Paul,

When you open the demo document click to check a box, a user form should appear. Since "clicking" (as compared to tabbing) in a checkbox content control triggers a state change this constitutes a "change" event. Now while you are still in the CC "uncheck" it. This is another "change" event detected by the monitor. You can change the state back and forth without ever exiting (or re-entering) the CC and the "change" event is triggered each time.