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