3
Answers

Problem with calling managed code dll from Excel

leitner

leitner

20y
3.5k
1
Hello! I try to use an assembly I created in C# in Excel. I use the commands csc, tlbexp & regasm to create the necessary files. I can use the library without any problem on my computer. When I try to make the assembly work on another computer, I copy the dll and tlb file to the other machine and run regasm there. I can add the reference to the file out of Excel, but when I want to use my object in the VBA-code I get the Error message "Run-time error '-2147024894 (80070002)' Automation Error The system cannot find the file specified" Does anyone know what to do? Thanks in advance! w.
Answers (3)
0
Abhishek Singh
NA 5.3k 1.1m 10y
Hi,

<asp:gridview ID="Gridview1" runat="server" AutoGenerateColumns="False" OnRowDataBound="Gridview1_RowDataBound" ShowFooter="True">
        <Columns>
            <asp:BoundField DataField="CustomerID" HeaderText="ID" />
            <asp:TemplateField HeaderText="Name">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("firstname") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("firstname") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
            <asp:Label ID="lbl" runat="server" Text="Total Amount" />
         </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Amount">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("amount") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("amount") %>'></asp:Label>
                </ItemTemplate>

                <FooterTemplate>
            <asp:Label ID="lblTotal" runat="server" />
         </FooterTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:gridview>
  

Code:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace gridViewTest
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        decimal total = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.populateData();
            }
        }

        public void populateData()
        {
            DataTable dt = new DataTable();


            dt.Columns.Add("CustomerID");
            dt.Columns.Add("FirstName");
         
            dt.Columns.Add("Amount");
            dt.Rows.Add("0001", "Abhishek", 10000);
            dt.Rows.Add("0002", "Ram", 20000);
            dt.Rows.Add("0003", "Alice", 30000);
            dt.Rows.Add("0004", "David", 40000);
           
            Gridview1.DataSource = dt;
            Gridview1.DataBind();

        }

        protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
        {

         
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                Label Amount = (Label)e.Row.FindControl("Label1");

                decimal Presents = Convert.ToDecimal(Amount.Text);
                total += Presents;

            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {

                Label lblTotal = (Label)e.Row.FindControl("lblTotal");

                lblTotal.Text = total.ToString();

            }



        }
    }
}

Hope this helps.
Accepted