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.
Syncfusion Feedback

Insert BookmarkEnd into Section.ChildEntities

Thread ID:

Created:

Updated:

Platform:

Replies:

90238 Sep 23,2009 08:41 AM UTC Jul 18,2014 09:18 AM UTC Windows Forms 4
loading
Tags: DocIO
Motunrayo Ogunyinka
Asked On September 23, 2009 08:41 AM UTC

Hi,

I need to delete content between two paragraphs in a word document. I can Identify the paragraphs and have inserted the bookmark start before the first paragraph.

If the second paragraph is in the same seciton as the first, then I want to insert the bookmarkend before the second paragraph. If not then I want to insert the bookmarkend as the last item in the section. My aim is to delete the first paragraph and everything following it until (but excluding the second paragraph).

I tried the following:
int stopEntityIndex = -1;
try
{
stopEntityIndex = section.ChildEntities.IndexOf(secondParagraph);
}
catch(ArgumentOutOfRangeException)
{

}

if (stopEntityIndex == -1)
{
stopEntityIndex = section.ChildEntities.Count - 1;
}

BookmarkEnd end = new BookmarkEnd(outDoc,"bkmark");
section.ChildEntities.Insert(stopEntityIndex , end as Entity);

My problem is that I get a System.InvalidOperationException when I try to insert saying {"Cannot insert an object to SectionChildEntities collection."}


Vijayakumar S [Syncfusion]
Replied On September 24, 2009 07:24 AM UTC

Hi Motunrayo,

Thank you for using Syncfusion products.

We have prepared a sample to achieve your requirement. Could you please have a look at the sample in the below link which inserts the bookmarkstart and bookmarkend for your requirement and delete the contents of the bookmark. Please try running this sample and let us know if this helps.

sample: http://files.syncfusion.com/support/DocIO.Windows/F90238/F90238.zip

Please let us know if you have any questions.

Regards,
Vijay

Motunrayo Ogunyinka
Replied On September 24, 2009 09:13 AM UTC

Thanks for that, I've got it to work now

Vijayakumar S [Syncfusion]
Replied On September 24, 2009 09:39 AM UTC

Hi Motunrayo,

Thank you for your update.

Please let us know if you have any questions.

Regards,
Vijay

Charulatha Suryakumar
Replied On July 18, 2014 09:18 AM UTC

Hi Vijaykumar,

Please send me the attachment, I cant get it on the link which you gave. I also want the code to insert childentities on the section

Got the same issue "Cannot insert an object to SectionChildEntities collection."

Regards
Charulatha Suryakumar

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.

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

;