Sub FAXP()
n = 1
TotalP = ActiveDocument.Paragraphs.count
Do While n < TotalP
counter = ActiveDocument.Paragraphs(n).Range.Words(1)
If counter <> "-----------------------------------------------------------------------------" Then
ActiveDocument.Paragraphs(n).Range.Words(1).Select
Selection.MoveLeft Unit:=wdCharacter, count:=1
InsertImage Trim(counter)
Else
Exit Sub
End If
n = n + 1
Loop
End Sub
Sub InsertImage(VARIABLEcounter)
On Error Resume Next
Selection.InlineShapes.AddPicture FileName:= _
"C:\Users\Person\Desktop\" & VARIABLEcounter & ".JPG", LinkToFile:=False, _
SaveWithDocument:=True
End Sub
Also remember, that counter in your defintion will not cut the the word only by the space, but also by the "_" for instance. So alternative would be to split the paragarph to an array by by space:
Sub FAXP()
n = 1
TotalP = ActiveDocument.Paragraphs.count
Do While n < TotalP
vParagraphText = ActiveDocument.Paragraphs(n).Range
vParagraphWords = Split(vParagraphText, " ")
counter = vParagraphWords(0)
If ActiveDocument.Paragraphs(n).Range.Words(1) <> "-----------------------------------------------------------------------------" Then
ActiveDocument.Paragraphs(n).Range.Words(1).Select
Selection.MoveLeft Unit:=wdCharacter, count:=1
InsertImage Trim(counter)
Else
Exit Do
End If
n = n + 1
Loop
End Sub
Sub InsertImage(VARIABLEcounter)
On Error Resume Next
Selection.InlineShapes.AddPicture FileName:= _
"C:\Users\Person\Desktop\" & VARIABLEcounter & ".jpg", LinkToFile:=False, _
SaveWithDocument:=True
End Sub