Copy and Paste text from external unopened document using VB in Word

I am trying to copy a paragraph from an external, unopened document to the activedocument.

I am using the below code however am receiving an error stating that no text is selected.

I'm very new to VB so have just trying to figure this out using similar coding I'm finding on the internet.

Sub ThisDocuemnt()

Dim docA As Document
Dim docB As Document

Set docA = ActiveDocument
Set docB = Documents.Open("Z:\xxxxx.doc")

docB.Bookmarks("Demo").Range.Select
docB.Bookmarks("EndDemo").Range.Select
docB.Bookmarks("EndDemo").Range.Copy
docA.Bookmarks("PasteDemo").Range.Paste

End Sub

Open in new window


Any help on how to identify the selection of text would be great. I've tried using .start and .end as identifiers of where to start the selection and where to end the selection but that isn't working either.
Kate HardmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
You do not need to use two bookmarks to designate a Document Range, nor do you need to select the range, so this should do:
Sub CopyTwixtBookmarks()

Dim docA As Document
Dim docB As Document

Set docA = ActiveDocument
Set docB = Documents.Open("Z:\xxxxx.doc")

docB.Bookmarks("Demo").Range.Copy
docA.Bookmarks("PasteDemo").Range.Paste

End Sub

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Automation

From novice to tech pro — start learning today.