View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cindy M. Cindy M. is offline
external usenet poster
 
Posts: 2,416
Default Does .Delete work in Word2003 11.5604.5606

Hi ?B?TWFydHk=?=,

And I know that "[cover sheet]" is being deleted. It's just that in the
If...Then clause, deletion does not occur. The verbiage between
"[transmittal]" and "[added pages]" does not get deleted, but "[transmittal]"
and "[added pages]" do.

*THAT* I would expect, yes. I read your original message through numerous times
to try to determine if that's what you meant. But you asked whether DELETE
works, so I had to assume *nothing* was being deleted, thus the Find not
executing completely.

When you execute FIND, and it is successful, the selection (or range) moves to
that position. "Extend" won't come into the equation because the selection will
go right to the "found" thing.

You need to work with a pair of ranges; one for the starting point, one for the
ending point. Roughly like this (untested). If you want to see what the various
ranges are doing, stick rngStartTag.Select and rngEndTag.Select in there and
step through the code, switching back to the doc window to see what gets
selected.

Dim rngStartTag as Word.Range
Dim rngEndTag as Word.Range

Set rngStartTag = ActiveDocument.Content
Set rngEndTag = ActiveDocument.Content

If LPPCI0.AddedPages.Value True Then
rngStartTag.Find.Execute FindText:="[transmittal]"
rngStartTag.Collapse wdCollapseEnd
Set rngEndTag.Start = rngStartTag.End
rngEndTag.Find.Execute FindText:="[added pages]"
rngStartTag.End = rngEndTag.Start
rngStartTag.Delete
'To repeat the search, you need to reset the ranges
'Set rngStartTag.End = ActiveDocument.Content.End
'Set rngEndTag = rngStartTag.Duplicate
End If


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)