Visual Studio 2015。
我遵循这个简短的教程在Word中创建了一个CustomTaskPane。我已经设法让它起作用了。我也想为Microsoft做同样的事情,但我遇到了第一个障碍:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
namespace WordAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
UserControl1 uc = new UserControl1();
Microsoft.Office.Tools.CustomTaskPane ctp = CustomTaskPanes.Add(uc, "Title");
ctp.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}上面的方法适用于一个单词AddIn,但是当我试图为一个项目AddIn执行它时,我会得到以下错误:
严重性代码描述项目文件行错误名称‘D:\DevProjects\MSProjectAddIn1\MSProjectAddIn1\ThisAddIn.cs’在当前上下文MSProjectAddIn1 17中不存在
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using MSProject = Microsoft.Office.Interop.MSProject;
using Office = Microsoft.Office.Core;
namespace MSProjectAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
UserControl1 uc = new UserControl1();
Microsoft.Office.Tools.CustomTaskPane ctp = CustomTaskPanes.Add(uc, "Title");
ctp.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}有人为CustomTaskPane创建了MSProject吗?
发布于 2015-11-27 14:46:12
经过大量的谷歌搜索,我在发布到堆栈交换后不久就找到了一个答案--不知道为什么,但访问CustomTaskPanes的方式在MSProject中是不同的:
UserControl1 uc = new UserControl1();
Microsoft.Office.Tools.CustomTaskPaneCollection customPaneCollection;
customPaneCollection = Globals.Factory.CreateCustomTaskPaneCollection(null, null, "Panes", "Panes", this);
Microsoft.Office.Tools.CustomTaskPane ctp = customPaneCollection.Add(uc, "Title");
ctp.Visible = true;https://stackoverflow.com/questions/33957427
复制相似问题