J
James Pannozzi
Trying to search for the word "Totals"
which occurs towards the end of some tables,
and insert 3 rows above it, then underline two of the
newly inserted rows.
Can't seem to do it without mixing up the range
and causing an infinite loop.
Here's the code
For Each oTbl In objWord.ActiveDocument.Tables
Set oRg = oTbl.Range
With oRg.Find
.ClearFormatting
.Text = "Totals"
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
oRg.Rows(1).Range.Select
Selection.InsertRowsAbove 3
' range gets messed up, finds same "Total For" again and again.
Loop
End With
Next
Thanks
Jim
which occurs towards the end of some tables,
and insert 3 rows above it, then underline two of the
newly inserted rows.
Can't seem to do it without mixing up the range
and causing an infinite loop.
Here's the code
For Each oTbl In objWord.ActiveDocument.Tables
Set oRg = oTbl.Range
With oRg.Find
.ClearFormatting
.Text = "Totals"
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
oRg.Rows(1).Range.Select
Selection.InsertRowsAbove 3
' range gets messed up, finds same "Total For" again and again.
Loop
End With
Next
Thanks
Jim