|
操作步骤如下:
新建项目 excel 工作薄
位置 D:\abc
Sheet1中画了个按钮
添加代码如下:(只有红色部分是自己加的,其它都是自动生成)
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
namespace ExcelWorkbook2
{
public partial class Sheet1
{
private void Sheet1_Startup(object sender, System.EventArgs e)
{
}
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO 设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InternalStartup()
{
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);
this.Startup += new System.EventHandler(this.Sheet1_Startup);
}
#endregion
private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i < 11; i++)
{
for (int j = 1; j < 11; j++)
{
Cells[i, j] = i;
}
} }
}
}
问题:编译后得到的这个工作薄,为什么只能在D:\abc这个目录下的原始位置运行???
(如果将该工作薄复制到其它位置,按钮不能使用)
[ 本帖最后由 HHAAMM 于 2009-4-12 00:58 编辑 ] |
|