D
Doug Robbins - Word MVP
Hi Thejan,
MsgBox ActiveDocument.Bookmarks("\line").Range.Characters.Count
will display the number of characters (including spaces in the line in which
the selection is located + 1.
The following should be of some help to you:
Dim myrange As Range, i As Integer, j As Integer
j = 1
While j <= ActiveDocument.Paragraphs.Count
Do
If j > ActiveDocument.Paragraphs.Count Then Exit Do
ActiveDocument.Paragraphs(j).Range.Select
Selection.Collapse wdCollapseStart
Set myrange = ActiveDocument.Bookmarks("\line").Range
For i = ActiveDocument.Bookmarks("\line").Range.Words.Count - 1 To 1
Step -1
ActiveDocument.Bookmarks("\line").Range.Words(i).Select
myrange.End = Selection.End
If myrange.Characters.Count < 73 Then
myrange.InsertAfter vbCr
Exit For
End If
Next i
j = j + 1
Loop
Wend
It is not a complete solution for what you want to do however as it will
only deal with there originally being only one paragraph in the document.
It will split that paragraph up into individual paragraphs of no more than
73 characters each.
If the head and the body were in separate sections, each containing only one
paragraph, then you could use
ActiveDocument.Sections(Index).Range.Paragraphs.Count
You might first have to run a macro that does a couple of Edit Replaces to
insert Section Breaks around the head text and the body text so that you
could deal with it section by section.
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.
Hope this helps
Doug Robbins - Word MVP
MsgBox ActiveDocument.Bookmarks("\line").Range.Characters.Count
will display the number of characters (including spaces in the line in which
the selection is located + 1.
The following should be of some help to you:
Dim myrange As Range, i As Integer, j As Integer
j = 1
While j <= ActiveDocument.Paragraphs.Count
Do
If j > ActiveDocument.Paragraphs.Count Then Exit Do
ActiveDocument.Paragraphs(j).Range.Select
Selection.Collapse wdCollapseStart
Set myrange = ActiveDocument.Bookmarks("\line").Range
For i = ActiveDocument.Bookmarks("\line").Range.Words.Count - 1 To 1
Step -1
ActiveDocument.Bookmarks("\line").Range.Words(i).Select
myrange.End = Selection.End
If myrange.Characters.Count < 73 Then
myrange.InsertAfter vbCr
Exit For
End If
Next i
j = j + 1
Loop
Wend
It is not a complete solution for what you want to do however as it will
only deal with there originally being only one paragraph in the document.
It will split that paragraph up into individual paragraphs of no more than
73 characters each.
If the head and the body were in separate sections, each containing only one
paragraph, then you could use
ActiveDocument.Sections(Index).Range.Paragraphs.Count
You might first have to run a macro that does a couple of Edit Replaces to
insert Section Breaks around the head text and the body text so that you
could deal with it section by section.
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.
Hope this helps
Doug Robbins - Word MVP