G
Greg
Hello Masters,
I was using the following lines of code to supply the ".Find" text in a
macro. The words to be found are in single column table with the
heading "Find" and stored in another document.
For i = LBound(ListArray) To UBound(ListArray) - 1 Step 2
With rngstory.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ListArray(i)
On Error GoTo Done
.Replacement.Text = Format(Left(ListArray(i), 1), ">") &
Right(ListArray(i), Len(ListArray(i)) - 1)
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
End With
Next i
Done:
The object of the macro was to look for these words in a document. If
found, First Cap the word and bold the word.
It works, but there are/were two problemns. First, if the table had
more rows than words and error is generated at the .Replacement line.
Error handling is my weakest link. I got around this by simply
skipping out of the macro with the On Error GoTo line. Is this the
right way?
Second problem was the heading in the table. If the word "find" was
included in the document text it was being processed as well. How do
you tell the macro to skip the first row? This is what I came up with:
For i = 2 To UBound(ListArray) - 1 Step 2
but I don't really understand why or how it works. Thanks for any
enlightenment you can offer.
I was using the following lines of code to supply the ".Find" text in a
macro. The words to be found are in single column table with the
heading "Find" and stored in another document.
For i = LBound(ListArray) To UBound(ListArray) - 1 Step 2
With rngstory.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ListArray(i)
On Error GoTo Done
.Replacement.Text = Format(Left(ListArray(i), 1), ">") &
Right(ListArray(i), Len(ListArray(i)) - 1)
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
End With
Next i
Done:
The object of the macro was to look for these words in a document. If
found, First Cap the word and bold the word.
It works, but there are/were two problemns. First, if the table had
more rows than words and error is generated at the .Replacement line.
Error handling is my weakest link. I got around this by simply
skipping out of the macro with the On Error GoTo line. Is this the
right way?
Second problem was the heading in the table. If the word "find" was
included in the document text it was being processed as well. How do
you tell the macro to skip the first row? This is what I came up with:
For i = 2 To UBound(ListArray) - 1 Step 2
but I don't really understand why or how it works. Thanks for any
enlightenment you can offer.