1
我有简单的c#outlook插件,它将当前字体保存在一个按钮单击事件上,并在第二个事件中恢复它。System.ArgumentException还原ActiveInspector.WordEditor.Application.Selection.Font
private void button1_Click(object sender, RibbonControlEventArgs e)
{
var a = Globals.ThisAddIn;
Outlook.Inspector inspector = a.Application.ActiveInspector();
if (inspector.EditorType == OlEditorType.olEditorWord)
{
Word.Document doc = inspector.WordEditor;
Word.Application app = doc.Application;
FontArr.Push(app.Selection.Font);
}
}
private void PopFormat_Click(object sender, RibbonControlEventArgs e)
{
var a = Globals.ThisAddIn;
Outlook.Inspector inspector = a.Application.ActiveInspector();
if (inspector.EditorType == OlEditorType.olEditorWord)
{
Word.Document doc = inspector.WordEditor;
Word.Application app = doc.Application;
Word.Font f = FontArr.Pop();
app.Selection.Font = f; // at this line exception occurs.
}
}
在此先感谢。
我修改类似的代码: FontArr.Push(app.Selection.Font.Duplicate); 没有工作:(。 – vmiheer