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. Image for the cookie policy date

Convert syntaxe from word to docio

hi,
1/ i have a document that contains two bookmark  "start" and "end" , iwant to delete the entity between the two bookmarks.
2/ how can i use backspace in docio
3/ can i convert this part of code from word9 to docio

wordObj.WorkDocument.Range(wordObj.WorkDocument.Bookmarks.Item("start").Start,wordObj.WorkDocument.Bookmarks.Item("end").End).Select()
wordObj.WorkDocument.ActiveWindow.Selection.Delete()
wordObj.WorkDocument.ActiveWindow.Selection.TypeBackspace()
wordObj.WorkDocument.ActiveWindow.Selection.MoveUp(Unit:=Word9.WdUnits.wdLine, Count:=1)
wordObj.WorkDocument.ActiveWindow.Selection.Tables.Item(1).Delete()
wordObj.WorkDocument.ActiveWindow.Selection.TypeBackspace()
wordObj.WorkDocument.ActiveWindow.Selection.TypeBackspace()
wordObj.WorkDocument.ActiveWindow.Selection.TypeBackspace()
wordObj.WorkDocument.ActiveWindow.Selection.TypeBackspace()

thanks

1 Reply

DB Dilli Babu Nandha Gopal Syncfusion Team March 14, 2019 03:00 PM UTC

Hi AtliDev, 

Regarding want to delete the entity between the two bookmarks:
You can delete the bookmark contents in the Word document using BookmarksNavigator in DocIO. Please refer the below documentation link to know about deleting content from bookmark in Word document using DocIO:
https://help.syncfusion.com/file-formats/docio/working-with-bookmarks#deleting-content-from-a-bookmark

Regarding how can i use backspace in DocIO:
We suspect that your requirement is to remove some elements in the Word document. Essential DocIO is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries to iterate with the document elements explicitly and perform necessary manipulation. To achieve your requirement we suggest you to iterate through the document elements and remove the element using DocIO.

If you face some difficulties to find and remove the particular the element in the Word document, you can also use find and replace functionality and replace with empty value.

Regarding can i convert this part of code from word9 to DocIO:
From the given code example, we suspect that your requirement to remove the bookmark contents and table in the Word document. You can iterate into the Word document and remove the elements using DocIO.

Please refer the below documentation links to know more about working with Word document using DocIO:
Iterating through document elements
Working with paragraph
 

Regards, 
Dilli babu. 


Loader.
Live Chat Icon For mobile
Up arrow icon