We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Creating new doc with GetBookmarkContent() from another doc

Thread ID:





72800 Apr 7,2008 04:17 AM UTC Jun 11,2014 11:42 AM UTC ASP.NET Web Forms (Classic) 4
Tags: DocIO
Asked On April 7, 2008 04:17 AM UTC

Hi, I would like to navigate to a book mark in DOC1 and select the contect between the start and end of that bookmark and copy that content to another new doc. How can I do this? please post any code samples.

Administrator [Syncfusion]
Replied On April 8, 2008 12:27 PM UTC

Hi Yogesh,

Thank you for your interest in Syncfusion products.

DocIO has the support for navigating through the bookmarks in a document. You can use the below code for Creating new doc with GetBookmarkContent() from another doc:

bodyPart = bk.GetBookmarkContent();
IWParagraph p= document1.AddSection().AddParagraph() ;
p.AppendText("this is the second document");
//Paste the first document bookmark content into another document[document1]

Here is the sample for your reference:

Please try this and let me know if this helps.


Yogesh Ramakrishnan
Replied On May 13, 2008 01:03 AM UTC

Hi, here is my code, let me know why this code does not work as I expect it to.

'Get the template path
Dim ExamplePath As String = My.Settings.ExamplePath.ToString()
Dim TemplatePath As String = My.Settings.TemplatePath.ToString()

' Create a new document
doc = New WordDocument(TemplatePath & "Examples.dot")

If dsExample.Tables.Count > 0 AndAlso dsExample.Tables(0).Rows.Count > 0 Then

'get the filename.
Dim exampleFilename As String = dsExample.Tables(0).Rows(0)("Example_FileName").ToString() & ".doc"

'Open the file
Dim exampledoc As WordDocument = New WordDocument(System.IO.Path.Combine(ExamplePath, exampleFilename))

'The bookmark in the example
Dim bookmarkname As String = dsExample.Tables(0).Rows(0)("Example_BM_S").ToString()

'Get the book mark navigator
Dim bk As BookmarksNavigator = New BookmarksNavigator(exampledoc)

'get the Book mark for given Name

Dim bp As TextBodyPart = bk.GetBookmarkContent()

bp = bk.GetBookmarkContent()

Dim p As IWParagraph = doc.AddSection().AddParagraph()
p.AppendText("this is the Example document")


End If
return doc

Bhuvaneswari P [Syncfusion]
Replied On May 27, 2008 08:55 AM UTC

Hi Yogesh,

Thanks for the code snippet.

We have tested using the same code but we are not able to reproduce the issue. We have tested this issue in the below environment:

Windows XP with Service pack2, office 2003 with sp3, VisualStudio 2005, .Net Framework 2.0 and Essential Studio version


Could you please send us the modified sample with the below details.

1. System configuration
2. Office version
3. Essential studio version.

This would be help us to invetigate more on this issue and provide you an solution.

Best Regards,

Paul Griffiths-DUPLICATE ACCOUNT- USE DT# 147667
Replied On June 11, 2014 11:42 AM UTC


I've been trying to do something very similar, selecting the entire content of the main sections of my document and inserting these as bookmarks.
What I have found is the the bookmark navigator GetBookmarkContent() method falls over when the bookmark content spans over a section break.

Can you confirm that this is a limitation I have with bookmarks? Or is there a way I can still use bookmarks that span over a section break?




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon