C# 尝试运行Excel加载项时出现FileNotFoundException 使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用System.Xml.Linq; 使用Excel=Microsoft.Office.Interop.Excel; 使用Office=Microsoft.Office.Core; 使用Microsoft.Office.Tools.Excel; 命名空间ExcelAddIn1 { 公共部分类ThisAddIn { 私有用户控制1用户控制; 专用Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane; 私有void ThisAddIn_启动(对象发送方,System.EventArgs e) { userControl=newusercontrol1(); //myCustomTaskPane=this.CustomTaskPanes.Add(myAddIn,“我的任务窗格”); myCustomTaskPane=this.CustomTaskPanes.Add(用户控件,“输入文本”); myCustomTaskPane.Visible=true; } 私有void ThisAddIn_关闭(对象发送方,System.EventArgs e) { } #区域VSTO生成的代码 /// ///设计器支持所需的方法-不修改 ///此方法的内容与代码编辑器一起使用。 /// 私有void InternalStartup() { this.Startup+=new System.EventHandler(ThisAddIn\u启动); this.Shutdown+=new System.EventHandler(ThisAddIn\u Shutdown); } #端区 } }
我创建了一个Excel加载项,它使用带有2个按钮的用户控件向Excel工作表中添加文本和图像。我编译的代码没有错误,但在运行时引发了以下异常 找不到指定的文件(HRESULT异常:0x80070002)C# 尝试运行Excel加载项时出现FileNotFoundException 使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用System.Xml.Linq; 使用Excel=Microsoft.Office.Interop.Excel; 使用Office=Microsoft.Office.Core; 使用Microsoft.Office.Tools.Excel; 命名空间ExcelAddIn1 { 公共部分类ThisAddIn { 私有用户控制1用户控制; 专用Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane; 私有void ThisAddIn_启动(对象发送方,System.EventArgs e) { userControl=newusercontrol1(); //myCustomTaskPane=this.CustomTaskPanes.Add(myAddIn,“我的任务窗格”); myCustomTaskPane=this.CustomTaskPanes.Add(用户控件,“输入文本”); myCustomTaskPane.Visible=true; } 私有void ThisAddIn_关闭(对象发送方,System.EventArgs e) { } #区域VSTO生成的代码 /// ///设计器支持所需的方法-不修改 ///此方法的内容与代码编辑器一起使用。 /// 私有void InternalStartup() { this.Startup+=new System.EventHandler(ThisAddIn\u启动); this.Shutdown+=new System.EventHandler(ThisAddIn\u Shutdown); } #端区 } },c#,excel,excel-addins,C#,Excel,Excel Addins,我创建了一个Excel加载项,它使用带有2个按钮的用户控件向Excel工作表中添加文本和图像。我编译的代码没有错误,但在运行时引发了以下异常 找不到指定的文件(HRESULT异常:0x80070002) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
namespace ExcelAddIn1
{
public partial class ThisAddIn
{
private UserControl1 userControl;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
userControl = new UserControl1();
//myCustomTaskPane = this.CustomTaskPanes.Add(myAddIn, "My Task Pane");
myCustomTaskPane = this.CustomTaskPanes.Add(userControl, "Enter Text");
myCustomTaskPane.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
}
}