问题
We are inserting content controls programmatically in word document and we don't want to add actions to the undo stack of word. The only way that we found is to access the undo commandbar-combobox and to remove the items related to inserting content control action, we are using the code below :
var commandBars = _wordDocument.CommandBars.Cast<CommandBar>();
var standardCommandBar = commandBars.First(bar => bar.Name.Equals("Standard"));
CommandBarComboBox undoControl =
standardCommandBar.Controls
.Cast<CommandBarControl>()
.First(control => control.Id == 128) as CommandBarComboBox;
undoControl.RemoveItem(1);
The last line undoControl.RemoveItem(1)
throws a ComException HRESULT E_FAIL
.
Is there any way to remove actions from the undo redo combo box?
来源:https://stackoverflow.com/questions/10703893/prevent-actions-to-be-added-to-the-word-undo-redo-or-remove-actions-from-the-und