locked
Not able to import microsoft.office RRS feed

  • Question

  • User438798737 posted

     i have created a windows application, in which i am using an excel sheet  for some calculations.

    when i build the application i am getting the following error.

    error: type Microsoft.Office.Interop.Excel.Application is not  defined.

     code is: 

    Imports Microsoft.Office.Interop
    Imports Microsoft.Office.Interop.Excel


    Public Class RA
        Dim excel As Microsoft.Office.Interop.Excel.Application

        Dim workBook As Microsoft.Office.Interop.Excel.Workbook

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            excel = New Microsoft.Office.Interop.Excel.Application
            workBook = excel.Workbooks.Open("d:\\aa.xls")
            Excel.Visible = True
        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'CHECK FOR AREA ADEQUACY BASED ON INPUTS
            Dim workSheet As Microsoft.Office.Interop.Excel.Worksheet

            'ASSIGN THE WORKSHEET TO THE REQUIRED ONE.
            workSheet = workBook.Worksheets("Sheet1")

            'ASSIGN THE INPUT TEXTBOXES VALUES TO RESPECTIVE EXCEL SHEET CELLS.
            workSheet.Cells(2, 1) = TextBox1.Text

            'GET THE OUTPUT CELL VALUES FROM THE EXCEL SHEET INTO THE OUTPUT TEXTBOXES.
            TextBox2.Text = DirectCast(workSheet.Cells(2, 2), Excel.Range).Value2.ToString()
        End Sub 
    End Class

     

    also i m not getting office as an option when i write import microsoft. but others are available - sqlserver,visualbasic and win32

     Please Help me in this... 

    Monday, April 20, 2009 2:23 AM

All replies

  • User-189778016 posted

    Hi

    (1)  You must have office installed on that machine for this code to work. I presume thats the case. Office dlls are exposed via COM dll files. In add reference under COM tab, you must be able to find them. look for something like "Microsoft Office 12.0 Object Library" or "Microsoft.Word.* dll".

    Once the reference to the above file is added, you must see a Interop.Office Or interop.Word.dll coming up. After this your code should execute.

    Hope that helps

    VJ

    Monday, April 20, 2009 4:36 AM
  • User438798737 posted

    i have office 2003 installed in my system.

    i m refering in COM tab to "Microsoft Office 11.0 Object Library"

     As i investigated there is no Microsoft.Office.Interop.Excel.dll present in the asembly folder of my system.

    i downloaded and added the same still the same error occurs.

     

    Monday, April 20, 2009 8:33 AM