【发布时间】:2015-07-30 04:33:47
【问题描述】:
我正在尝试将此 VBA 代码从 Outlook 插件转换为 C#
Private Sub objInspector_Activate() Handles objInspector.Activate
Dim wdDoc As Microsoft.Office.Interop.Word.Document = objInspector.WordEditor
wdDoc.Windows(1).Panes(1).View.Zoom.Percentage = lngZoom
End Sub
但我无法访问 Panes.View.Zoom.Percentage 属性
主要思想是当用户打开一封电子邮件时,他会得到一个自定义的缩放级别。
我现在得到的是:
void Inspector_Activate()
{
// this bool is true
// bool iswordMail = objInspector.IsWordMail();
//I get the word document
Document word = objInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
word.Application.ActiveDocument.ActiveWindow.View.Zoom.Percentage = 150;
// at this point i'm getting an exception
// I've also tried with
// word.ActiveWindow.ActivePane.View.Zoom.Percentage = 150; getting the same exception
}
例外是:
“System.Runtime.InteropServices.COMException”类型的异常 发生在 OutlookAddInTest.dll 中,但未在用户代码中处理
附加信息:此对象模型命令在 电子邮件。
我是 C# 和 Office 插件的新手,有什么建议吗?
【问题讨论】:
标签: c# vba outlook zooming outlook-addin