ExtendMode being turned off by WindowSelectionChange event

T

Tim

ExtendMode being turned off by WindowSelectionChange event

I have a class that contains a WindowSelectionChange event.
Whenever the event is triggered, the ExtendMode is being turned
off before the event routine is completed. This event is also affecting
the functionality of the F2 (MoveText) and the Format Painter functionality.

I can Email the test template to anyone that is interested in looking
at it ([email protected]) or it can be setup as follows:

Steps to setup test template

1. Create a Class module call ProcClass with the following contents:

Option Explicit
Public WithEvents MyWord As Word.Application

Private Sub MyWord_WindowSelectionChange(ByVal Sel As Selection)
iClassTrigger = iClassTrigger + 1
StatusBar = " Class triggered: " & CStr(iClassTrigger) & ", ExtendMode: "
& _
Selection.ExtendMode
End Sub

2. Create a code module with the following contents
Option Explicit

Public wdApp As New ProcClass
Public iClassTrigger As Integer

Sub AutoOpen()
Set wdApp.MyWord = Word.Application 'Initializes Class
End Sub

'These last 2 routines aren't required
Sub DestroyClass() 'Destroys Class
Set wdApp.MyWord = Nothing
End Sub

Sub CheckClass() 'Re-initializes Class if not found
If wdApp.MyWord Is Nothing Then
Set wdApp.MyWord = Word.Application
End If
End Sub

3. Save the template and then re-open it.
The statusbar will display incrementally the number of times the event was
triggered and the ExtendMode status.
If ExtendMode is ON, the ExtendMode will be turned off when the ChangeEvent
is completed.

Thanks in advance for your time looking at this.
 
W

Word Heretic

G'day Tim <[email protected]>,

This as per design requirements. ExtendMode ends when there is another
selection. Why not just re-enter extend mode at the end of your guff,
using the activeend of the required range as your base.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Tim reckoned:
 
T

Tim

Steve,

Thank you for your reply.

But I am confused. Here are my confusion points.

1. "ExtendMode ends when there is another selection."
Isn't the concept of ExtendMode that is stays ON as additional
objects are selected?

2. "Why not just re-enter extend mode at the end of your guff"
The ExtendMode is ON (last line of event) as indicated by the
StatusBar display. I tried adding another line
"Selection.ExtendMode = True", but still ended with the same
result.

Thanks for your help.

Tim
 
W

Word Heretic

G'day Tim <[email protected]>,

1. No, it is merely the stuff between a starting point and ending
point, both made by selections. It is not a 'spike' you can gather
random selections on.

2. Select the range created by 1. Maybe ScrollIntoView to view end.
Turn extend mode on.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Tim reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top