S
Sophia
Hello,
I have an rtf document open on Word97.
ActiveDocument.Sections.count =18
The sections are delimited by Section Breaks (Continuous)
I have, in the document, a list of words stored as Document
Variables.
I'm trying to find the first instance in each "Section"
of a word from that list and set the font for that "found" word
to "bold"... then go on through the list of words, setting any
other of the words from the list to bold ... then go on to the
next Section.
For some reason, instead of doing "For each Section", the
following code is doing "For each Paragraph" instead.
What am I doing wrong?
Public Sub aSetDocVarsToBold()
Dim mySCTN As Section
Dim oControl As Control
Dim i, SectionNumber
Dim myvar As Variable
For Each mySCTN In ActiveDocument.Sections
For Each myvar In ActiveDocument.Variables
If myvar.Value <> "" Then
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
.Wrap = wdFindContinue
.Execute FindText:=Trim(myvar.Value)
If .Found Then
Selection.Range.Font.Bold = True
End If
End With
End If
Next
Next
End Sub
TIA
Sophia
I have an rtf document open on Word97.
ActiveDocument.Sections.count =18
The sections are delimited by Section Breaks (Continuous)
I have, in the document, a list of words stored as Document
Variables.
I'm trying to find the first instance in each "Section"
of a word from that list and set the font for that "found" word
to "bold"... then go on through the list of words, setting any
other of the words from the list to bold ... then go on to the
next Section.
For some reason, instead of doing "For each Section", the
following code is doing "For each Paragraph" instead.
What am I doing wrong?
Public Sub aSetDocVarsToBold()
Dim mySCTN As Section
Dim oControl As Control
Dim i, SectionNumber
Dim myvar As Variable
For Each mySCTN In ActiveDocument.Sections
For Each myvar In ActiveDocument.Variables
If myvar.Value <> "" Then
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
.Wrap = wdFindContinue
.Execute FindText:=Trim(myvar.Value)
If .Found Then
Selection.Range.Font.Bold = True
End If
End With
End If
Next
Next
End Sub
TIA
Sophia