View Single Post
 
Old 01-20-2024, 03:24 PM
ctviggen ctviggen is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Feb 2021
Posts: 54
ctviggen is on a distinguished road
Default

This code works well, except that it adds the material pasted into the currently open document at the end of the document:
Code:
  
Set aRng = aDoc.Range   
 aRng.Collapse Direction:=wdCollapseEnd   
 aRng.FormattedText = newDoc.Range.FormattedText
What I would like is either
(1) select and copy all the text, but leave the text selected, and the material would be pasted in at the end of the selection (and I could add a carriage return before pasting); or

(2) after selection and copying of the text, I move the cursor to a blank line after the text I just selected.

I modified your code slightly to try this, where only the first line is modified:
Code:
  
Set aRng = Selection.Range   
 aRng.Collapse Direction:=wdCollapseEnd   
  aRng.FormattedText = newDoc.Range.FormattedText
This SEEMS to me like it should work, but it doesn't. Nothing gets pasted in regardless of whether I try (1) or (2). I'm stumped as to why.

(Also, as you said, the cross-referencing uses the "old" cross-referencing for the material that is pasted in, but I'll work on that later. Thanks for the information about this.)
Reply With Quote