G
Greg Strong
Why can't I use a variable for the count in the GoTo method to delete
merged text?
Basically the thought was to use a DoWhile Loop on a merged document to
go to the beginning of the second page of each section, go back 2 spaces
to get back to the end of the page 1 of that section and delete the text
on that line, then move on to the next section. The macro runs the
correct number of times, but the GoTo method is not moving past section
number 1. What I end up with is more deleted on the first page of the
first section rather the same codes on the first page of each section.
It appears the thought of using the "numCtr" on the "Count" of the GoTo
method is not working.
See the code below in the quote box with the question mark under the
questioned code. Any ideals? TIA!
,----- [ Macro ]
| Sub TestDeleteDocNo()
| '
| ' TestDeleteDocNo Macro
| ' Macro recorded 1/12/2004 by Greg Strong
| '
| Selection.EndKey Unit:=wdStory
| numRepeats = Selection.Information(wdActiveEndSectionNumber)
| Selection.HomeKey Unit:=wdStory
| numCtr = 1
|
| Do While numCtr < numRepeats
| Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=numCtr, Name:=""
| ?
|
| Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=2, Name:=""
| Selection.Find.ClearFormatting
| Selection.MoveLeft Unit:=wdCharacter, Count:=2
| Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
| Selection.Delete Unit:=wdCharacter, Count:=1
| Selection.HomeKey Unit:=wdStory
| numCtr = numCtr + 1
| Loop
|
| End Sub
`-----
Regards,
Greg Strong
merged text?
Basically the thought was to use a DoWhile Loop on a merged document to
go to the beginning of the second page of each section, go back 2 spaces
to get back to the end of the page 1 of that section and delete the text
on that line, then move on to the next section. The macro runs the
correct number of times, but the GoTo method is not moving past section
number 1. What I end up with is more deleted on the first page of the
first section rather the same codes on the first page of each section.
It appears the thought of using the "numCtr" on the "Count" of the GoTo
method is not working.
See the code below in the quote box with the question mark under the
questioned code. Any ideals? TIA!
,----- [ Macro ]
| Sub TestDeleteDocNo()
| '
| ' TestDeleteDocNo Macro
| ' Macro recorded 1/12/2004 by Greg Strong
| '
| Selection.EndKey Unit:=wdStory
| numRepeats = Selection.Information(wdActiveEndSectionNumber)
| Selection.HomeKey Unit:=wdStory
| numCtr = 1
|
| Do While numCtr < numRepeats
| Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=numCtr, Name:=""
| ?
|
| Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=2, Name:=""
| Selection.Find.ClearFormatting
| Selection.MoveLeft Unit:=wdCharacter, Count:=2
| Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
| Selection.Delete Unit:=wdCharacter, Count:=1
| Selection.HomeKey Unit:=wdStory
| numCtr = numCtr + 1
| Loop
|
| End Sub
`-----
Regards,
Greg Strong