Interop,撤消word撤消堆栈中的所有操作

时间:2010-09-08 10:00:32

标签: ms-word office-interop

我正在使用c#和word interop。 如何以编程方式撤消单词撤消堆栈中的所有操作?

问候。

1 个答案:

答案 0 :(得分:2)

以下是解决方案:

object times = 1;
while (worDocument.Undo(ref times))
{}

但在调用此代码之前,必须删除ContentControlBeforeDelete,ContentControlOnEnter和ContentControlOnExit之类的事件处理程序,否则会冻结文字http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/50a96ba1-85e3-498f-89bb-4181220a565f)。