View Single Post
 
Old 06-09-2021, 03:47 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

We normally try to avoid the selection object and copy/paste when they aren't necessary.

Add Dim aRng as Range to the top of the macro

Delete from objDoc.Range.Copy to End With
In that same location, add this code
Code:
Set aRng = objNewDoc.Range
aRng.Collapse Direction:=wdCollapseEnd
aRng.FormattedText = objDoc.Range.FormattedText
As an aside, you can merge multiple files like this without code.
1. Create a new document
2. Go to Insert > Object > Text from File
3. Pick multiple files (Select and Shift+Select)
4. Click OK
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote