Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Marty Marty is offline
external usenet poster
 
Posts: 28
Default Does .Delete work in Word2003 11.5604.5606

Hi-

I have some VBA code:


If LPPCI0.AddedPages.Value True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[transmittal]"
.ExtendMode = True
.Find.Execute FindText:="[added pages]"
.Delete
End With
End If

If LPPCI3.OptionButton17 True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[added pages]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With
End If

When I step through, I can see the cursor going to each and every line. Both
LPPCI0.AddedPages and LPPCI3.OptionButton17 are false. But it does not seem
to be deleting the portions of the document between [transmittal] & [added
pages] and between [added pages] & [cover sheet]. Why???? Does .Delete not
work?

[transmittal], [added pages] & [cover sheet] are all in the .dot template.
The verbiage is not being deleted after the mailmerge.

It's driving me nuts.

Please help.

Thanks.
  #2   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=?=,

When you step into and beyond a find.execute line, does the selection actually
change to select, for example, [transmittal]?

You aren't specifying most of the Find properties and methods (ClearFormatting
being important, among others). When you use the Selection object with Find,
any and everything set in the Find dialog will be applied. Such as MatchCase or
MatchWildcards. Possibly something in the dialog box is making it so things
aren't found?

I have some VBA code:


If LPPCI0.AddedPages.Value True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[transmittal]"
.ExtendMode = True
.Find.Execute FindText:="[added pages]"
.Delete
End With
End If

If LPPCI3.OptionButton17 True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[added pages]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With
End If

When I step through, I can see the cursor going to each and every line. Both
LPPCI0.AddedPages and LPPCI3.OptionButton17 are false. But it does not seem
to be deleting the portions of the document between [transmittal] & [added
pages] and between [added pages] & [cover sheet]. Why???? Does .Delete not
work?

[transmittal], [added pages] & [cover sheet] are all in the .dot template.
The verbiage is not being deleted after the mailmerge.


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 :-)

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Marty Marty is offline
external usenet poster
 
Posts: 28
Default Does .Delete work in Word2003 11.5604.5606

Thanks Cindy.

I have some code after that which is listed:


With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[cover sheet]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With

The above code is duplicated for "[transmittal]" and "[added pages]"


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.

I'm stumped.

-Marty

"Cindy M." wrote:

Hi ?B?TWFydHk=?=,

When you step into and beyond a find.execute line, does the selection actually
change to select, for example, [transmittal]?

You aren't specifying most of the Find properties and methods (ClearFormatting
being important, among others). When you use the Selection object with Find,
any and everything set in the Find dialog will be applied. Such as MatchCase or
MatchWildcards. Possibly something in the dialog box is making it so things
aren't found?

I have some VBA code:


If LPPCI0.AddedPages.Value True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[transmittal]"
.ExtendMode = True
.Find.Execute FindText:="[added pages]"
.Delete
End With
End If

If LPPCI3.OptionButton17 True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[added pages]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With
End If

When I step through, I can see the cursor going to each and every line. Both
LPPCI0.AddedPages and LPPCI3.OptionButton17 are false. But it does not seem
to be deleting the portions of the document between [transmittal] & [added
pages] and between [added pages] & [cover sheet]. Why???? Does .Delete not
work?

[transmittal], [added pages] & [cover sheet] are all in the .dot template.
The verbiage is not being deleted after the mailmerge.


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 :-)


  #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 :-)

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word work file Chris Grigg Microsoft Word Help 3 June 26th 06 05:37 AM
Mail Merge Recipients box does not work millidge Mailmerge 4 December 8th 05 09:13 PM
How to request photos of an artist's work from a business? Jamalla New Users 1 November 4th 05 06:14 PM
How To Make Numbering Work Right? Peyton Todd Page Layout 2 December 17th 04 06:53 PM
Trying to make numbering work... Peyton Todd Microsoft Word Help 5 December 16th 04 07:12 PM


All times are GMT +1. The time now is 04:11 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"