【发布时间】:2014-05-23 06:44:42
【问题描述】:
我正在创建一个 MS Word VSTO。在 VSTO 中,我添加了一个自定义任务窗格,在 MS Word 的右侧显示我的用户控件。这是添加自定义任务窗格的代码sn-p。
Public WithEvents _taskPane As Microsoft.Office.Tools.CustomTaskPane
Private myTaskPaneCollection As Microsoft.Office.Tools.CustomTaskPaneCollection
myTaskPaneCollection = Globals.Factory.CreateCustomTaskPaneCollection _
(Nothing, Nothing, "CustomTaskPanes", "CustomTaskPanes", Me)
_taskPane = myTaskPaneCollection.Add(dvPanel, My.Resources.dvTaskPane)
_taskPane.Control.Dock = Windows.Forms.DockStyle.Left
_taskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight
_taskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal
_taskPane.Width = 300
_taskPane.Visible = True
注意:DVPANEL 是我的用户控件,它将显示有关已打开文档的元数据。
I have written this code at Application.DocumentOpen() function as I want to display task pane only when any document is opened. It work fine when i run it from MS Visual Studio. But when I opened any Document from my application. It fails. Here is the snapshot of actual error.
我搜索了很多,但无法获得更多信息。这是我参考过的链接。 http://social.msdn.microsoft.com/forums/vstudio/en-US/205cdc8b-3b20-4cb8-ad30-c6177e9f8435/argument-null-reference-exception-project-addin
提前致谢。等待好评。
【问题讨论】: