hi i am creating a program that needed an excel app., and i already do it, at first no error, but after a sudden, an error appeal, here is a error. Microsoft.Office.Interop.Excel.Application' is not defined.
i am still new and still exploring in vb.net. thank you in advance!
Any help is highly appreciated :)

Recommended Answers

All 5 Replies

Can you post some code? looks like you have a object type where it expects a defined variable.

 Dim appXL As Excel.Application
        Dim wbXl As Excel.Workbook
        Dim shXL As Excel.Worksheet
        'Dim raXL As Excel.Range
        'Start Excel and get Application object.
        appXL = CreateObject("Excel.Application")
        appXL.Visible = True
        'Add a new workbook.
        wbXl = appXL.Workbooks.Add
        shXL = wbXl.ActiveSheet
        'Add table headers going cell by cell.
        shXL.Cells(1, 1).Value = ""

        'Format A1:D1 as bold, vertical alignment = center.
        With shXL.Range("A", "IV")
            .Font.Bold = True
            .VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
        End With
        'raXL = shXL.Range("1", "1")
        'raXL.Formula = "=  "" ""  "
        'With shXL
        '    .Cells(2, 4).Value = ""
        '    .Cells(3, 4).Value = ""
        '    .Cells(4, 4).Value = ""
        '    .Cells(5, 4).Value = ""
        '    .Cells(6, 4).Value = ""
        'End With
        'AutoFit columns A:K.
        ''raXL = shXL.Range("A1", "K1")
        ''raXL.EntireColumn.AutoFit()
        'Make sure Excel is visible and give the user control of Excel's lifetime.
        appXL.Visible = True
        appXL.UserControl = True
        ' Release object references.
        'raXL = Nothing
        shXL = Nothing
        wbXl = Nothing
        appXL.Quit()
        appXL = Nothing
        Exit Sub
Err_Handler:
        MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)

that 's my code..

You have to create the object by

 Dim appXL As New Excel.Application

CreateObject is how you would do it in vbScript, not vb.net. See here for an example.

You also have code that appears outside the Sub/End Sub (Err_Handler:). Not good. I assume that somewhere you have an On Error GOTO. You should be using Try/Catch instead.

1) Check your Excel dll references.
2) when you deal with excel object , your machine should have Ms office pakage and have permission to access that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.