At the end of our a Word2010 document we've a numbered list of 6 items. We would like to add a text, say, End of Document
at the end of that document using VBA
. But when I try the following code it always add a new list item (item 7) to the list with that text as shown in image below. NOTE: We don't have control over the document. So the last line of the document is always item number 6 of the list and when a user runs VBA code the code is supposed to add last line at the end of the document as End of document.
And this line should not be the last item of the list.:
Sub test()
Dim oList As List
Set oList = ActiveDocument.Lists(1)
oList.Range.InsertParagraphAfter
oDoc.Content.InsertAfter "End of Document";
End Sub
Snapshot of the list at the End of a document: