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.
Unfortunately, activation email could not send to your email. Please try again.

Creating new doc with GetBookmarkContent() from another doc

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 08:27 AM

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:


[C#]
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]
bodyPart.PasteAfter(p.Items[0]);
document1.Save("sample2.doc");


Here is the sample for your reference:
http://websamples.syncfusion.com/samples/DocIO.Web/6.1.0.34/72800/main.htm

Please try this and let me know if this helps.

Regards,
G.Yavana



Yogesh Ramakrishnan
Replied On May 12, 2008 09:03 PM

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
bk.MoveToBookmark(bookmarkname)

Dim bp As TextBodyPart = bk.GetBookmarkContent()

bp = bk.GetBookmarkContent()

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

bp.PasteAfter(p.Items(0))



End If
return doc



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

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 6.2.0.40.
Sample:

http://websamples.syncfusion.com/samples/DocIO.Web/6.1.0.34/72800/main.htm


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,
Bhuvana


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

Hi,

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?

Cheers

Paul

CONFIRMATION

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.

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.

;