G
Greg Maxey
Can someone please explain this strange behavior:
Open a new blank document.
Put cursor in the header.
Run the following code:
Sub TestStoryType()
Dim oRng As Range
Set oRng = Selection.Range
oRng.WholeStory
MsgBox oRng.StoryType 'Will correctly display "7"
ValidateParagraphs oRng
MsgBox oRng.StoryType 'Story type has changed to "12" !!!!!????
End Sub
Private Sub ValidateParagraphs(ByRef oRng As Range)
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Text = "^13"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
End Sub
The ValidateParagraphs routine will of course insert result in a second
paragraph mark being created. If you run the above proceeds a second type
the msgbox will then report "7" both before and after the ValidateParagraphs
routine. Why is the strorytype changing to 12 on the first run??
Open a new blank document.
Put cursor in the header.
Run the following code:
Sub TestStoryType()
Dim oRng As Range
Set oRng = Selection.Range
oRng.WholeStory
MsgBox oRng.StoryType 'Will correctly display "7"
ValidateParagraphs oRng
MsgBox oRng.StoryType 'Story type has changed to "12" !!!!!????
End Sub
Private Sub ValidateParagraphs(ByRef oRng As Range)
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Text = "^13"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
End Sub
The ValidateParagraphs routine will of course insert result in a second
paragraph mark being created. If you run the above proceeds a second type
the msgbox will then report "7" both before and after the ValidateParagraphs
routine. Why is the strorytype changing to 12 on the first run??