Copy bookmark from Documet to Document

B

Barry

I am try to copy bookmark from one word doc to another, find all the
bookmark and select them etc.

I can create the bookmark in the second word doc, with the correct
name.

The problem is set the location of the bookmark

Any help here would be great

WrdDoc is the destination doc
WrdTemplate is the source doc


-----------------------------------------

If WrdDoc.Bookmarks.Count = 0 Then
'# Set Template Document Path
Dim strTemplatePath As String = "C:\Temp\test.doc"

'# Open Template
WrdTemplate = WrdApp.Documents.Open(strTemplatePath)

'# Get BookMarks
For Each BookMark As Word.Bookmark In
WrdTemplate.Bookmarks
Debug.Print(BookMark.Name.ToString)
---- WrdDoc.Bookmarks.Add(BookMark.Name,
bookmark.range) ------- Problem Here

Next
WrdTemplate.Close()

i get the following error

The specified range is not from the correct document or story.

Understand what the error is saying, but have not got a clue to how to
get around it.
 

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