A
AG
Hello,
This is probably easy, but I don't find the answer. Here is my macro (Office 2007). It enumerates my titles, but when reaching the last one, it loops over it again and again. I have tried the different .Wrap possibilities, but they all give the same result. How can I stop my search after having enumerated all my titles?
AG.
Sub macro1()
Dim rgDcm As Range
Set rgDcm = ActiveDocument.Range
With rgDcm.Find
.ClearFormatting
.Style = ActiveDocument.Styles("Titre 1")
.Replacement.ClearFormatting
.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While rgDcm.Find.Execute
MsgBox rgDcm.Text
Loop
End Sub
This is probably easy, but I don't find the answer. Here is my macro (Office 2007). It enumerates my titles, but when reaching the last one, it loops over it again and again. I have tried the different .Wrap possibilities, but they all give the same result. How can I stop my search after having enumerated all my titles?
AG.
Sub macro1()
Dim rgDcm As Range
Set rgDcm = ActiveDocument.Range
With rgDcm.Find
.ClearFormatting
.Style = ActiveDocument.Styles("Titre 1")
.Replacement.ClearFormatting
.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While rgDcm.Find.Execute
MsgBox rgDcm.Text
Loop
End Sub