Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Go to closest editable area

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dan.KSU@gmail.com - 30 Jan 2007 19:10 GMT
I have a template in Word 2003 that uses partion protection.  Certain
areas of the doc have full edit capabilities while others are not
editable.

What I want to do is anytime the user clicks or selects inside a
protected area, I want it to move their cursor to the closes or next
editable area.

I have found very little on the events that drive the Protection Task
Pane.  This is were I think the needed event resides.

All help is welcomed and appreciated!

Cheers,

Daniel Stevens
Shauna Kelly - 31 Jan 2007 09:43 GMT
Hi Daniel

myRange.GoToEditableRange(wdEditorCurrent) will move the selection to the
next editable range.

But Word doesn't expose any events related to areas of the document that are
protected. And, Word does not expose any events that fire when the user
moves the cursor by typing or by using the arrow keys. So on the face of it
there's no way to detect when a user moves into or out of an unprotected
region.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I have a template in Word 2003 that uses partion protection.  Certain
> areas of the doc have full edit capabilities while others are not
[quoted text clipped - 12 lines]
>
> Daniel Stevens
Tony Jollans - 31 Jan 2007 17:53 GMT
It is true that Word does not expose any events that fire when the user
moves the cursor by typing but ...

... the WindowSelectionChange Event does fire when the user moves the
cursor with the arrow keys or clicks somewhere with the mouse so that can
catch a lot - probably everything you want to.

Try something like this:

Private Sub wd_WindowSelectionChange(ByVal Sel As Selection)

   Dim UserPos As Range
   Dim EditablePos As Range
   Set UserPos = Selection.Range.Duplicate
   Set EditablePos = UserPos.GoToEditableRange
   If UserPos.Start > EditablePos.End Then
       ' tried to select past last range - just go to beginning of it
       UserPos.Start = EditablePos.Start
       UserPos.End = EditablePos.Start
   Else
       ' If selection starts before an editable range move the start to the
start of that range
       ' If the end is also before the start move end to the start as well
       ' If the end is after the end of the editable range pull it back in,
else leave it alone
       If UserPos.Start < EditablePos.Start Then
           UserPos.Start = EditablePos.Start
           If UserPos.End < EditablePos.Start Then
               UserPos.End = EditablePos.Start
           ElseIf UserPos.End > EditablePos.End Then
               UserPos.End = EditablePos.End
           Else
           End If
       Else
           ' Selection already starts in an editable range - leave it alone
           ' If the end is after the end of the editable range pull it back
in, else leave it alone
           If UserPos.End > EditablePos.End Then
               UserPos.End = EditablePos.End
           End If
       End If
   End If
   ' Select the amended range
   UserPos.Select

End Sub

Signature

Enjoy,
Tony

> Hi Daniel
>
[quoted text clipped - 28 lines]
>>
>> Daniel Stevens

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.