"ArthurN" wrote:
> Thanks a lot for help,
> Unfortunately, for some reason I can't run the script in the following lines:
> rgeSec.SetRange .Parent.End + 1,
> and
> .InsertAfter k + 1 & "." & vbTab & vbTab & vbTab &
> They give an error each time I try to run them.
>
> * The stories in a documents are separated from each other by a page break.
>
Be careful when copying code from the internet/newsgroups. Often lines are
broken by the message browser.
Normally, you can easily spot those lines in the VBA editor because the code
is in red.
In this case,
rgeSec.SetRange .Parent.End + 1,
ActiveDocument.Sections(i).Range.End
should be on one line:
rgeSec.SetRange .Parent.End + 1, ActiveDocument.Sections(i).Range.End
Or, you can use the line continuing character:
rgeSec.SetRange .Parent.End + 1, _
ActiveDocument.Sections(i).Range.End
The same for:
.InsertAfter k + 1 & "." & vbTab & vbTab & vbTab &
strArrWordsSort(k) & vbCrLf
One line:
.InsertAfter k + 1 & "." & vbTab & vbTab & vbTab & strArrWordsSort(k) & vbCrLf
Or,
.InsertAfter k + 1 & "." & vbTab & vbTab & vbTab _
& strArrWordsSort(k) & vbCrLf