D
David Joseph Bonnici
Hi, i tried to find a way to extract the words that are in bold in a
word document. I have written this code.
intBoldState = 0
For lngRangeTrack = 1 To lngWholeStory Step 500
objWord.Selection.SetRange Start:=lngRangeTrack,
End:=(lngRangeTrack + 499)
For Each objItem In objWords
'Debug.Print " lngRangeTrack = " & lngRangeTrack & " to "
& lngRangeTrack + 9
If ((oldWordStart = objItem.Start)) Then
'Do nothing
Else
oldWordStart = objItem.Start
oldWordEnd = objItem.End
If (intBoldState <> objItem.Bold) Then
intBoldState = objItem.Bold
tso.Write (vbNewLine)
End If
tso.Write (objItem.Text)
'Debug.Print objItem.Text & " Start: " & objItem.Start
& " End: " & objItem.End
End If
Next
Next
What is happening is that, not all the words are appearing in the
objItem. Every now and then it skips a character, and I am quite sure
that it is not due to my fault.
David
word document. I have written this code.
intBoldState = 0
For lngRangeTrack = 1 To lngWholeStory Step 500
objWord.Selection.SetRange Start:=lngRangeTrack,
End:=(lngRangeTrack + 499)
For Each objItem In objWords
'Debug.Print " lngRangeTrack = " & lngRangeTrack & " to "
& lngRangeTrack + 9
If ((oldWordStart = objItem.Start)) Then
'Do nothing
Else
oldWordStart = objItem.Start
oldWordEnd = objItem.End
If (intBoldState <> objItem.Bold) Then
intBoldState = objItem.Bold
tso.Write (vbNewLine)
End If
tso.Write (objItem.Text)
'Debug.Print objItem.Text & " Start: " & objItem.Start
& " End: " & objItem.End
End If
Next
Next
What is happening is that, not all the words are appearing in the
objItem. Every now and then it skips a character, and I am quite sure
that it is not due to my fault.
David