It looks like that code pastes BEFORE anything has been copied - so it assumes you copied something before the code was run. If not, where did the clipboard contents come from? Assuming you wanted the selection from openDoc then you could have used instead
newDoc.Range.FormattedText = aRng.FormattedText
Looping through bookmarks from the start and removing+adding bookmarks while you are doing it is problematic - however in this case it appears you are getting away with it.
Can you explain why you want the original text put in there twice with bookmarks named with two different series? I would envisage that if there are any Cross-Refs outside the original selection in openDoc, they will be broken after the _Ref bookmarks are removed. Wouldn't it be better to leave that one set there and just introduce the _New section after or before it?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|