I have a macro I adapted from another question on Experts Exchange (https://www.experts-exchange.com/questions/27585165/Microsoft-Word-Macro-to-Find-Copy-and-Paste-Text-with-Specific-Style-to-a-new-Document.html
) that I am trying to enhance.
I want it to extract all text that has a user-defined style to a new document but also to include the numbering if the style is a numbering style. I added these lines to achieve the latter, but they do not do the job:
Set oRange = oDoc.Range(Start:=rText.Start, End:=rText.End)
'Then undo so that numbers revert to the original in oDoc
The idea was to convert the numbers to text to preserve them in the output document but revert to their dynamic state in the source document (this macro would be a great tool to check to see where the list numbering is off wherever it occurs in the document).
The macro also goes into an endless loop when entering ‘Body Text’, ‘Body Text 2’, ‘List Number’, List Number 2, but not ‘Body Text 3’, ‘List Number 3’ (of those I tested). I added a counter to catch the endless loop at some point and display a message box to that effect, but I don’t understand why the macro does this on some styles and not on others.
Can someone help prevent the endless loop and get the macro to properly include the numbering when the style contains numbering?