VSTO Word 2007: How can a control be programmatically moved above/below the range of an existing control? - ms-word

I am developing a Word 2007 document template with VSTO. The document has several RichTextContentControls and there is a visible ActionsPane with a treeview control where the nodes of the treeview are the names of the RichTextContentControls.
Users can re-order nodes by dragging/dropping nodes to new locations in the treeview. As nodes are dropped, the corresponding RichTextContentControls should be re-ordered according the new node locations.
I am able to find the Range of the control that the new control is supposed to be moved above of. Now I only need to find a way to simply...move the control to this new location.
How can I move a control above/below a range?

I did this with a bookmark inside of a RichTextControl to just move it above/below another one from two buttons in the actions pane. Like this for moving up where "bm" below equals the selected bookmark:
Dim pageBookmark As Microsoft.Office.Tools.Word.Bookmark
pageBookmark = Globals.ThisDocument.Controls.Item(bm)
pageBookmark.Range.Relocate(Direction:=Word.WdRelocate.wdRelocateUp)
For a tree view, it would be more complex, but I could see that you would want all your richtext controls to be indexed (maybe use the "tag" property) and then as you move them in your tree view, use the index to add/subtract from other indexes and then use the "Relocate" method in a loop that many times to get it to it's new location. Then you can loop and recreate the index. Application.ScreenUpdating = False at the start of the loops and set it back to = True at the end of the loop would stop the flicker as well.

Related

How can I create an unknown and changing number of unconnected ToggleButtons based on an input?

There is a file that can be edited containing a number and that many unconnected ToggleButtons should appear.
I'd provide code but I have no idea where to start so here is the idea:
user selects a class
a number of dropdown boxes relative to the class pop-up asking the user to select 1/0 of (mana/health/strength/speed/defence) each of which increases the relevant stat by 1 and removes the previous increase if there was one.
(changing the class restarts from number 2)
The issue is that I cannot know the numbers available and so have to have a way to create any number of togglebuttons, however, they each need their own isSelected array and I don't know how to create a dynamic number of toggle button to reference each one separately.
Is there any way to use a for loop or something to create z number of togglebuttons each referencing a different element from a list of isSelecteds?
I've been able to create 2d array where each array is an isSelected for each togglebutton but I've been unable to find a way to create all the togglebuttons where each one gets a different element in the array to use as its isSelected.

How do I refer the shape's data from sub-shape of Visio custom shape

I'm trying to design a custom shape in Visio.
My structure is like this:
In the "Edit Master" page I have some rectangles, I called my shape "MyDay", so that's its document's name in the Master Explorer and in the edit window.
My problem is, that I can't find a way to refer the shape's date itself (like =MyDay!Name() or =MyDay!User.MyUserField) from one of my sub-shapes.
If I add a reference to ThePage and drop the master on a page - I adds that property to the page itself - again - no reference to the main shape from its sub-shapes.
I know there is no "Parent" property in ShapeSheet formulas (only on VBA), but I'm really trying to find a way to refer it using fields or formulas, without the need to write and run VBA code.
Many appreciations for any help!
Paul is correct, but I will add that it is normally expected that a Master contains only one shape, but that can be a group shape that contains other shapes. Therefore, a formula in a sub-shape can refer to any shape in that group, including the top level group shape, using the Sheet.n syntax. When an instance of the master shape is dropped onto a page, then Visio will automatically update the n ID to the actual shape ID in the page. The shape ID has to be unique within the shapes collection that it is part of, so the top-level group shape needs to be assigned a new unique ID, but the sub-shapes do not because they already have an ID that is unique within the shapes collection that they are part of.
You need to find the parent shape's Sheet reference number (select it and then ribbon Developer -> Shape Name -> Shape). This will be something like Sheet.6.
Use this reference in your formula e.g.
Sheet.6!User.MyUserField

How to detect cursor entering and leaving a table using content control ID

I am working on word addin using office js
I have a requirement to detect whether user has entered and moved out of a table during review. I have created the table under a content control. What I need to implement if I click/put cursor using key at any column of table then a global variable value will change to true and when cursor moves outside that table then the variable changes to false and I shall assume user has done some change in table(even if they actually haven't) and I shall save the whole document.
Using below method I am able to detect generic cursor movement event.
Office.context.document.addHandlerAsync("documentSelectionChanged", mySelectionHandler,
function (result) {
//write(result.value)
}
);
However, I couldn't find any mechanism to assert my cursor is within a table or outside that table. Could you help on this?
You could try using getSelection to get the Range object where the cursor currently is. Then call the Range object's parentTableOrNullObject or parentContentControlOrNullObject properties to determine if the cursor is in a table/content control. Then use the id or title properties to identify the table the cursor is in.

Inserting a new paragraph between two existing tables

In a TinyMce textarea, I have a content where several tables directly follow each other (there's no content between the tables themselves). Using TinyMce, I want to allow my users to insert a new paragraph between those tables... but that doesn't seem possible?... (Not sure whether I'm missing something or if it's an oversight.)
If I try to click between the tables (even if they have a CSS margin applied), the cursor goes immediately inside the closest cell of one of the tables. Same thing if I move the cursor with the keyboard arrow keys: it jumps from table 1 to table 2 without stopping between them. So there's no way to add a new element between those tables.
I sometimes work with ckEditor on Drupal projects, and it has a sort of red horizontal line that appears on hover, when you move your mouse between block-level elements. Clicking on this red line allows to insert a new paragraph between those blocks. Is there some equivalent for TinyMCE? (Or another solution?)
Use your mouse to target the end of the table and then hit enter. In this fiddle I created http://fiddle.tinymce.com/Vygaab/1 I add one table, add a second table, then use my mouse target the end of the first table.
Note that neither table should be selected, and when you target the end of the first table, it shouldn't show as selected.
Then if you hit enter, you should get a new paragraph. In this fast example, I took the borders off the table so you can see the cursor blinking more easily.
This was built with the latest Cloud Stable version.

What ExtJS 4.2 standard function gets executed for grid selection when using Ext.selection.RowModel (default) selModel?

There is a bug with the way the Ext.grid.Panel rowexpander plugin works when a nested grid is set to renderTo to the rowexpander div id.
When this is implemented, it's difficult to see what is actually being selected. The reason for this is because the config "disableSelection" and "trackMouseOver" are to be both considered for highlighting. I have to set "trackMouseOver: false" so that hovering over grid rows doesn't interfere with reproducing this behavior. Then "disableSelection: false" must be set so that this selection issue does actually occur.
The issue is that when you select index 1 of the nested grid of parent grid index 0 row, index 1 row of parent grid is selected as well. If you select index 2 of the nested grid of parent grid index 0 row, index 2 of parent grid is selected as well.
When 935424 is selected, 815138 is selected since they are both index 0.
When 1056257 is selected, 1013525 is selected since they are both index 1.
When 1200191 is selected, 1261631 is selected since they are both index 2.
I'm suspecting that the selection model instance might be getting shared with the grid and nested grids since I'm using the same definition. They are of course different instances of the same definition, but I'm not sure how the framework handles additional grids using Ext.create?
I'd like to ask how to fix it or get me close, I'll be up-voting you (often). But if you can at least give me a clue as to where this selection function is being called in the framework, that will get me on the right track and can debug and discover a fix for it. I've read that events can bubble, and maybe that's what's happening here. It seems to have a handle on the row as well, because when I double click the nested grid row, it not only tries to expand that row, but also the row from the parent grid row (that matches the row index).
After any recursive nested grid is created, I had to call this line so the click and dblclick (and others) events don't bubble/propagate to the parent grid.
grid[cnt].getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick', 'onRowFocus']);
How did you load the selection model ?
selModel: 'rowselection',
Or
selModel: Ext.create('Ext.selection.RowModel'),
If you use the first syntax, you should get an independent selection model for each grid. If you use the second syntax, you get only one selection model that is shared among all grid instances.