B
Boram
I'm having trouble getting the correct paragraph count for a document
after stripping it of the soft return/vertical tab character (Chr(11))
and replacing it with the carriage return character (Chr(13)).
Even after saving, closing and reopening the target file to ensure
that ActiveDocument has been refreshed, the paragraph count still
turns out to be incorrect.
The following code demonstrates this bug:
'***************************************************************
Sub Test()
'Create file
Documents.Add
'Add 9 vert tab chars to the initial carriage return char
For i = 1 To 9
Selection.TypeText Chr(11)
Next i
'Set breakpoint here, verify that CountBefore = 1
CountBefore = ActiveDocument.Paragraphs.Count
'Replace vertical tab chars with paragraph chars
ActiveDocument.Range.Find.Execute FindText:=Chr(11), _
ReplaceWith:=Chr(13), _
Replace:=wdReplaceAll
'Set breakpoint here, verify that CountAfter = 1, although I want
'this to be 10
CountAfter = ActiveDocument.Paragraphs.Count
End Sub
'***************************************************************
The Paragraphs Collection doesn't get updated and Word behaves as if
it knows that the replaced characters used to be soft return
characters (Chr(11)).
Thanks in advance,
Boram
after stripping it of the soft return/vertical tab character (Chr(11))
and replacing it with the carriage return character (Chr(13)).
Even after saving, closing and reopening the target file to ensure
that ActiveDocument has been refreshed, the paragraph count still
turns out to be incorrect.
The following code demonstrates this bug:
'***************************************************************
Sub Test()
'Create file
Documents.Add
'Add 9 vert tab chars to the initial carriage return char
For i = 1 To 9
Selection.TypeText Chr(11)
Next i
'Set breakpoint here, verify that CountBefore = 1
CountBefore = ActiveDocument.Paragraphs.Count
'Replace vertical tab chars with paragraph chars
ActiveDocument.Range.Find.Execute FindText:=Chr(11), _
ReplaceWith:=Chr(13), _
Replace:=wdReplaceAll
'Set breakpoint here, verify that CountAfter = 1, although I want
'this to be 10
CountAfter = ActiveDocument.Paragraphs.Count
End Sub
'***************************************************************
The Paragraphs Collection doesn't get updated and Word behaves as if
it knows that the replaced characters used to be soft return
characters (Chr(11)).
Thanks in advance,
Boram