Hi ,
I need to traverse through a word document that contains many bookmarks. Some of these bookmarks have child bookmarks within them as well.
What I need to do is extract the contents of each individual bookmark and write the text out to a file . It works fine when it’s a single bookmark, although if the bookmark has children then the contents of the children are also extracted as part of the parent extract.
How do I avoid this from occurring so that regardless of the level of the bookmark I can just extract the individual content.
Regards,
Sam
Hi Sam,
Thanks for your inquiry. In your case we suggest you following solution.
1) Clone the document.
2) Set the child bookmark’s text to empty string using Bookmark.Text property.
3) Extract the content of parent bookmark.
Please read following article about extracting contents. Hope this helps you.
Hi Tahir,
Thanks for your reply … I have just about got it … The problem I am having is that the children content is getting extracted at the same time.
Im am rather stuck … I would post my code but it’s in DataFlex so you may not be able to understand it as such …
My understanding is that
1) I can just get the number of bookmarks.
2) Iterate through each and extract the name. This works.
3) I then need to extract the content which I can but it is also extracting child bookmark content.
I think I am missing something somewhere . I just need someone to tell me what it is …
Sam
Hi Sam,
Thanks for your inquiry. Please use the solution shared in my previous post. You need to check either parent bookmark contains children bookmarks or not. If there are children/nested bookmark, remove the bookmark’s contents using Bookmark.Text property. Set its value to empty string.
If you still face problem, please share your input document and expected output documents here for our reference. We will then provide you more information about your query.