VSTO Word 2007: How can I programmatically move controls above / below the range of an existing control?

I am developing a Word 2007 document template with VSTO. There are several RichTextContentControls in the document, and there is a visible Actions panel with a treeview control, where the treeview nodes are the names of RichTextContentControls.

Users can reorder nodes by dragging nodes to new places in the tree. As nodes are deleted, the corresponding RichTextContentControls must be reassigned to the new node locations.

I can find Range of the control that the new control should be moved higher. Now I just need to find a way to just ... move the control to this new place.

How can I move the control above / below the range?

+3
source share
1 answer

I did this with a bookmark inside RichTextControl to just move it above / below the other with two buttons on the action bar. For example, to move up, where "bm" is lower than the selected bookmark:

Dim pageBookmark As Microsoft.Office.Tools.Word.Bookmark
pageBookmark = Globals.ThisDocument.Controls.Item(bm)
pageBookmark.Range.Relocate(Direction:=Word.WdRelocate.wdRelocateUp)

, , , richtext (, "tag" ), , , / , "" , , . . Application.ScreenUpdating = False = True .

+4

Source: https://habr.com/ru/post/1707358/


All Articles