外接程序已经弄好了。就是在Excel2007上加载了我自定义的控件。有个问题,我把解决方案生成的时候,生成出来的是dll文件,然后我就把这个dll文件放到另外一台没有任何环境的电脑上试,当然此电脑上装了Excel2007 还有 .net framework 3.5/4.0 两个都装了。问题就是,我把dll文件放到系统盘下 windows32里面,然后运行 regsvr32 ExcelAddIn1.dll(稍微解释一下,ExcelAddIn1是我创建程序的名称。) 就提示:已加载 ExcelAddIn1.dll,但没找到DllRegisterServer 输入点。无法注册这个文件      请问各位高手是啥问题啊?在网上找了很多资料也没解决。我还是个新手,才了解这个东西不久哦。各位大侠帮帮忙

解决方案 »

  1.   

    用 VSTO 开发AddIn 哪有这么麻烦?
      

  2.   

    http://blog.csdn.net/fangxinggood/article/details/6571566
      

  3.   

    这位大哥,这个好象是VB的写法啊.我用C#已经加载进去了。但是到客户端去试,不行哦。我直接把程序生成的Dll文件放过去 加载不了....求解...
      

  4.   

    你要是以COM方式开发Addin,看下面的bloghttp://www.cnblogs.com/brooks-dotnet/archive/2010/03/01/1675324.html
      

  5.   

    public partial class ThisAddIn
        {
            Office.CommandBarButton cmdBarControl = null;
            Office.CommandBarComboBox cmdBarControl2 = null;
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                addButton();
            }        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
            public void addButton()
            {
                #region
                //Office.CommandBarPopup cmdBarControl = null;
                //Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;
                //int controlCount = menubar.Controls.Count;
                //string menuCaption = "神马东西?(&P)";
                //// Add the menu.
                //cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, controlCount, true);
                ////cmdBarControl.Tag = menuTag;            //cmdBarControl2.DescriptionText = "sfsd";
                ////定义控件部分
                //Office.CommandBarComboBox cmdBarControl1 = null;
                //Office.CommandBarButton cmdBarControl2 = null;
                ////cmdBarControl2.Caption= "选择";            //Office.CommandBar menubar1 = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;
                //Office.CommandBar menubar2 = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;            //int controlCount1 = menubar1.Controls.Count;
                //int controlCount2 = menubar2.Controls.Count;            //string menuCaption1 = "哈哈?(&P)";
                //string menuCaption2 = "选择";            //// Add the menu.
                //cmdBarControl1 = (Office.CommandBarComboBox)menubar1.Controls.Add(Office.MsoControlType.msoControlComboBox, missing, missing, controlCount1, true);
                //cmdBarControl1.AddItem("第一列值", 1);
                //cmdBarControl1.AddItem("第二列值", 2);
                //cmdBarControl1.AddItem("第三列值", 3);
                //cmdBarControl1.Caption = menuCaption1;
                //cmdBarControl2 = (Office.CommandBarButton)menubar2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, controlCount2, true);            //cmdBarControl2.Caption = menuCaption2;
                //cmdBarControl.Tag = menuTag;
                #endregion            Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;
                menubar.Visible = true;            int controlCount = menubar.Controls.Count;
                //string menuCaption = "按钮";
                cmdBarControl = (Office.CommandBarButton)menubar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, controlCount, true);
                cmdBarControl.Caption = "选择";
                cmdBarControl.Tag = "选择";            Office.CommandBar menubar2 = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;
                int controlCount2 = menubar2.Controls.Count;
                string menuCaption2 = "下拉框";
                cmdBarControl2 = (Office.CommandBarComboBox)menubar2.Controls.Add(Office.MsoControlType.msoControlComboBox, missing, missing, controlCount2, true);
                cmdBarControl2.AddItem("代客批次明细表", 1);
                cmdBarControl2.AddItem("房费消费模式分类消费明细表", 2);
                cmdBarControl2.AddItem("充值金额明细表", 3);
                cmdBarControl2.ListIndex = 1;
                cmdBarControl2.Caption = menuCaption2;
                cmdBarControl2.Width = 500;
                cmdBarControl.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(cmdBarControl_Click);
            }
            private void cmdBarControl_Click(Microsoft.Office.Core.CommandBarButton cmdBarbutton, ref bool Cancel)
            {
                string SelectValues = this.cmdBarControl2.Text.ToString();
                Form1 F1 = new Form1(SelectValues);
                F1.ShowDialog();
            }
            #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
        }
    这个是我在Excel上加载的控件。再强调一下,我是用ASP.Net去做。最后生成的是Dll文件。放到另外一台电脑上(此电脑装了.net framework 3.5/4.0)上面。也装了Excel2007。但加载进去的时候就是包我那个Dll文件不是有效的office加载项求解,各位大侠。。
      

  6.   

    嗯 我是选的COM加载项。要不我说下我的操作步骤。第一、在Excel2007导航上右击选择自定义快书访问工具栏。第二、进去后在左边选择加载项。第三、在加载项界面的下面有个管理,我选择了COM加载项,然后转到。。第四、选择添加。第五、选择我那个Dll文件。一选择,就报我那个Dll文件不是有效的Office加载项。是不是我的程序编写有问题啊?如果有问题,我怎么能在我的编译机上能运行出来了?
      

  7.   

    看你这样,也不是COM加载项,搞得我都迷糊了你创建的工程模板是啥,这和asp.net有半毛钱关系啊?如果是VSTO,客户端还需要装 VSTO Runtime V3.0以上版本。还有PIA程序集。
      

  8.   

    我原先给你贴的文章虽然是VB.NET开发的但就是VSTO(用C#开发也就是语法不同而已),最后要在bin/debug下生成一个.vsto文件。这个就是加载项。部署到客户端需要有vsto runtime和PIA支持。编译的时候不需要选COM加载项
      

  9.   

    小弟我也是第一次弄这个东西。我也稀里糊涂了。我创建这个程序是在VS2010(在文件里面新建项目。)里面有个office,下面有个2010和2007 我选择了2007 在选择Excel2007外接程序。就在里面敲的代码。敲好后生成的是Dll文件。。
      

  10.   

    还有点我没说清楚。就是我通过在Excel上添加自定义控件后,点击控件我会弹出个Winform窗体。这个东西我在编译机上都能出来。但是放在其他的机子上 就连自定义加载项都没出来。就包错
      

  11.   

    0. 不需要选COM加载项目,VSTO通过”vsto文件“安装加载项
    1. bin/debug 下会看到 .dll 和 .vsto 两个文件,这是部署的主要输出文件。
    2. 客户端还需要安装 VSTO Runtime V4.0(因为你是VS2010开发的)
       http://www.microsoft.com/download/en/details.aspx?id=20479
       以及 Office PIAs 
       http://www.microsoft.com/download/en/details.aspx?id=18346
    3. 正常应该制作 Install 来部署的,简单的测试可以直接将
       [1.]里的(.dll和.vsto)拷贝到客户端(它两必需在一起),然后双击.vsto,这就和安装程序一样的。
    下面是完整的制作安装程序的blog:
    http://yaojian.blog.51cto.com/1581802/314063
      

  12.   

    这个大哥还在不?我刚看了一下。是有个vsto文件,难道要加载这个文件吗?我加载的时候 找不到这个文件哦。
      

  13.   

    这个大哥在吗?我在客户端机子上装了一下那个VSTO Runtime V4.0 X64的 报错误。说不是有效的win32应用程序。这怎么回事?
      

  14.   

    @___@ 自己选下版本厄。x64是给64bit操作系统用的。估计你那的客户端是x86(32bit)的PC。
    vstor40_x86.exe 下这个
      

  15.   

    两个都装了。现在就是在客户端双击那个vsto文件了是吧?