Macros to control table operations

D

Designingsally

I got 10 tables in ten different pages. Each table has different containts.
And the most common words i have found in each table are "english" and
"test". I want the macros to highlight only the first occuring instance of
the words "english" and "test" in each table and comment the first instance
of the words "english" and "test" in only in each table. Is this possible?

Thanks for the help in advance.
 
P

Pesach Shelnitz

Hi Sally,

I believe that you can write this macro yourself with a little help. My
basic approach would be to cycle through the Tables collection of the active
document using a For Each loop. For each table in the collection, you can use
the object held in the .Range.Find property to search for "english" and then
for "test". When each word is found, you do perform whatever actions you want.

Write back if you have any questions.
 
D

Designingsally

what this pesach. Pls tell me ur thoughts.



Dim oRng As Range
Dim rngTable As Range
Dim oTable As Table
Dim strFind(1) As String
Dim j As Integer
strFind(0) = "english"
strFind(1) = "test"
Set oRng = ActiveDocument.Range.Duplicate
For Each oTable In oRng.Tables
For j = 0 To 1
Set rngTable = oTable.Range
With rngTable.FInd
.Text = strFind(j)
.ClearFormatting
.Replacement.ClearFormatting
.MatchCase = False
.MatchWholeWord = True
.Execute
If .Found Then
rngTable.Select
Selection.comments.Add _
Range:=Selection.Range, Text:="Use ""Avoid using this
word."""
If strReplace <> "" Then
rngTable.Text = strReplace
End If
Selection.Collapse wdCollapseEnd
End If
End With
Next j
Next oTable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top