A
andreas
Below macro which I recently wrote is supposed to COPY all the text
that has been placed between brackets TO the end of the document and
list them one below the other. It is running fine with one exception.
If text between brackets is found in a table cell, the macro falls
into an endless loop. In theses cases, it copies the text between the
brackets over and over again and won't stop.
Hence, how do I have to re-write this code so that text between
brackets located in a table cell is also properly copied and put at
the end of the document.
Help is appreciated. Thank you very much in advance.
Regards, Andreas
Dim rng As Range
Dim rngEnd As Long
Set rng = ActiveDocument.Range
rngEnd = ActiveDocument.Range.End
With rng.Find
.Text = "\([!\)]@\)"
.MatchWildcards = True
Do While .Execute()
rng.Copy
ActiveDocument.Bookmarks("\EndOfDoc").Range.Paste
ActiveDocument.Bookmarks("\EndOfDoc").Range.InsertAfter
vbCr
rng.Collapse wdCollapseEnd
rng.End = rngEnd
Loop
End With
End Sub
that has been placed between brackets TO the end of the document and
list them one below the other. It is running fine with one exception.
If text between brackets is found in a table cell, the macro falls
into an endless loop. In theses cases, it copies the text between the
brackets over and over again and won't stop.
Hence, how do I have to re-write this code so that text between
brackets located in a table cell is also properly copied and put at
the end of the document.
Help is appreciated. Thank you very much in advance.
Regards, Andreas
Dim rng As Range
Dim rngEnd As Long
Set rng = ActiveDocument.Range
rngEnd = ActiveDocument.Range.End
With rng.Find
.Text = "\([!\)]@\)"
.MatchWildcards = True
Do While .Execute()
rng.Copy
ActiveDocument.Bookmarks("\EndOfDoc").Range.Paste
ActiveDocument.Bookmarks("\EndOfDoc").Range.InsertAfter
vbCr
rng.Collapse wdCollapseEnd
rng.End = rngEnd
Loop
End With
End Sub