View Single Post
 
Old 03-03-2024, 07:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote