PC Review


Reply
Thread Tools Rate Thread

Copy Word Doc Bookmarks from One Document to another (VB.net)

 
 
Barry
Guest
Posts: n/a
 
      9th Apr 2010
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.
 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      9th Apr 2010
Am 09.04.2010 10:47, schrieb Barry:
> 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.


I think you have a Word automation problem, not a VB.Net problem.
The guys in the Word VBA group should know it.


--
Armin
 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      9th Apr 2010
On 9 Apr, 09:53, Armin Zingler <az.nos...@freenet.de> wrote:
> Am 09.04.2010 10:47, schrieb Barry:
>
> > 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.

>
> I think you have a Word automation problem, not a VB.Net problem.
> The guys in the Word VBA group should know it.
>
> --
> Armin


It okay i have work it out

For Each BookMark As Word.Bookmark In WrdTemplate.Bookmarks
Dim NewRange As Word.Range
NewRange = WrdDoc.Range(BookMark.Range.Start,
BookMark.Range.End)
WrdDoc.Bookmarks.Add(BookMark.Name, NewRange)
Next

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I Import Bookmarks From Another Word Document? Word97User Microsoft Word Document Management 0 7th Jan 2009 03:56 PM
Hyperlink to bookmarks in Word document - works in Word 2003 not 2 =?Utf-8?B?QW50aG9ueSBZYXJlbWVua28=?= Microsoft Word Document Management 0 3rd Oct 2007 06:50 AM
Parse bookmarks in a word document Mike Fellows Microsoft VB .NET 2 9th Oct 2006 02:09 PM
Copy Bookmarks to new Document =?Utf-8?B?QmV0aA==?= Microsoft Word Document Management 1 14th Oct 2004 02:37 AM
Checking for bookmarks in Word document =?Utf-8?B?amFn?= Microsoft Excel Programming 2 14th Jun 2004 02:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:05 PM.