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 / February 2005

Tip: Looking for answers? Try searching our database.

selection extend problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
canbya@forecast1.com - 01 Feb 2005 20:38 GMT
Hi! Maybe someone will spot why I loose my extend selection when I try
to block after the second search? Appreciate your help.

' Removes existing contractor data
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Contractors"
.Style = "Heading 2"
.Forward = True
.Execute
If Not .Found Then GoTo SaveClose
End With

With Selection
.MoveRight Unit:=wdCharacter, Count:=2
.ExtendMode = False
.ExtendMode = True
End With   '*******works fine here

Selection.Find.ClearFormatting
'Leave notes alone
With Selection.Find
.Text = "NOTE(S):"
.MatchCase = True
.Forward = True
.Execute          '***works fine here
End With

If Selection.Find.Found Then GoTo SkipHead2
'check for nect section if note: not found

With Selection
.ExtendMode = False   '***does not shut off here
.ExtendMode = True     ' does not work
End With

With Selection.Find
.Text = "T"
.Style = "Heading 2"
.Forward = True
.Execute
End With                'loose the extend here
SkipHead2:
With Selection
.HomeKey Unit:=wdLine
.ExtendMode = True
End With
Selection.Delete Unit:=wdCharacter, Count:=1  'deletes the T xwrong
Helmut Weber - 02 Feb 2005 23:11 GMT
Hi,
very difficult to read from your code what you really want.
Especially
>.ExtendMode = False
>.ExtendMode = True
makes no sense to me.
Usually, these commands are very reliably.
Anyway,

>Selection.Find.ClearFormatting
>With Selection.Find
[quoted text clipped - 5 lines]
>
>If Selection.Find.Found Then GoTo SkipHead2 '!!!

causes a a new find process in the current selection,
I think, and from then on it's all a mess.
If you want to know, whether a find operation
has been successfull, use
if .execute then
or
while .execute
respectively

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
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.