VBA concatenate ranges into a new document

Joined
Jul 21, 2023
Messages
1
Reaction score
0
Hi,
i've got several ranges in my document which i want to export into a new word document. However when ever i paste into the new document it simply overwrites the previous entry. What am i doing wrong please?

This code is called from another looping function so startbm and endbm change each time eg start1, start3, start5

Set oRange = aDoc.Range(Start:= _
aDoc.Bookmarks(startBM).End, _
End:=aDoc.Bookmarks(endBM).Start)

oRange.Copy

If m_ObjDocument Is Nothing Then
Set m_ObjDocument = Documents.Add

End If

m_ObjDocument.Activate
Selection.EndKey Unit:=wdStory
m_ObjDocument.Range.Paste

i only ever end up with one range pasted into the new document.

I'm sure its an easy fix but I've battled it for ages and can't see what am i doing wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top