I'm sorry, but that doesn't help much. In both cases
Case 1 (the complete document text is):
FOTO
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Case 2 (the complete document text is):
FOTO
The macro performs exactly the same. It runs to the line Exit Sub and exits without error.
If the "next part" is intended to format text following the instance of "FOTO", then how could you possibly continue and format something that isn't there? I have tried to deduce what you are trying to do:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 4/5/2018
Dim oRng As Range
Dim oRngFormat As Range
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="FOTO", MatchWholeWord:=True)
oRng.Collapse wdCollapseEnd
On Error GoTo Err_Handler
Set oRngFormat = oRng.Paragraphs(1).Next.Range
With oRngFormat
.Font.Name = "Times New Roman"
.Font.Size = 8
.Font.Italic = wdToggle
.Bold = False
With .ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 10
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(0.9)
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
End With
.Collapse 0
End With
Loop
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
Err_Handler:
Resume lbl_Exit
End Sub
When you collapse a range to the its start point then it will "NEVER" be equal to the end of the next paragraph (if i