You are still interrogating a paragraph that doesn't exist, this time to establish what it's length is. There is no next paragraph after the last paragraph.
Sub add_sign_xml() Dim oPar As Paragraph For Each oPar In ActiveDocument.Range.Paragraphs If Not oPar.Range = ActiveDocument.Range.Paragraphs.Last.Range Then If oPar.Range.Characters.First = "<" _ And Not InStrRev(oPar.Range.Text, "-") > 0 _ And Not InStr(oPar.Next(1).Range.Text, "<tr>") > 0 Then oPar.Range.InsertAfter "add" End If End If Next End Sub




Reply With Quote