G
Greg Maxey
Does anyone know why shapes in the header or footer story ranges are treated
differently than shapes contained in the main text story?
If I put two shapes containing text (text containing one spelling error) in
the main text story and two shapes containing similar text in the header of
a document and run this code:
Sub CheckForErrors1()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
i = i + pRange.SpellingErrors.Count
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
This msgbox response is 2.
The correct response should be 4 which is the results of running this code:
Sub CheckForErrors2()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
Select Case pRange.StoryType
Case 6, 7, 8, 9, 10, 11
i = i + pRange.SpellingErrors.Count
If pRange.ShapeRange.Count > 0 Then
For Each oShp In pRange.ShapeRange
If oShp.TextFrame.HasText Then
i = i + oShp.TextFrame.TextRange.SpellingErrors.Count
End If
Next oShp
End If
Case Else
i = i + pRange.SpellingErrors.Count
End Select
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
Why do shapes in storyrange type 6, 7, 8, 9, 10 and 11 have to be treated
separately and individually?
Thanks.
differently than shapes contained in the main text story?
If I put two shapes containing text (text containing one spelling error) in
the main text story and two shapes containing similar text in the header of
a document and run this code:
Sub CheckForErrors1()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
i = i + pRange.SpellingErrors.Count
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
This msgbox response is 2.
The correct response should be 4 which is the results of running this code:
Sub CheckForErrors2()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
Select Case pRange.StoryType
Case 6, 7, 8, 9, 10, 11
i = i + pRange.SpellingErrors.Count
If pRange.ShapeRange.Count > 0 Then
For Each oShp In pRange.ShapeRange
If oShp.TextFrame.HasText Then
i = i + oShp.TextFrame.TextRange.SpellingErrors.Count
End If
Next oShp
End If
Case Else
i = i + pRange.SpellingErrors.Count
End Select
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
Why do shapes in storyrange type 6, 7, 8, 9, 10 and 11 have to be treated
separately and individually?
Thanks.