阻止将操作添加到单词undo redo中或从undo redo CommandBarComboBox中删除操作

时间:2012-05-22 14:15:39

标签: c# interop office-interop word-2010

我们在word文档中以编程方式插入内容控件,我们不希望将操作添加到word的undo堆栈中。我们找到的唯一方法是访问撤消命令栏 - 组合框并删除与插入内容控制操作相关的项目,我们使用以下代码:

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);

最后一行undoControl.RemoveItem(1)抛出一个ComException HRESULT E_FAIL

有没有办法从撤消重做组合框中删除操作?

0 个答案:

没有答案