Getting an "Excel.Application" is not defined error RRS feed

  • Question

  • In my ASP.Net project I have a reference to:

    C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Excel.dll

    and my VB codebehind page has this :

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

    but when I run the project I get this error:


    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30002: Type 'Excel.Application' is not defined.

    Source Error:

    Line 8:  Public Class ExcelIO
    Line 9:  	Private Shared iExcelPID As Integer
    Line 10: 	Private Shared xlExcel As Excel.Application = Nothing
    Line 11: 
    Line 12: 	Public Shared Sub ReadInput(ByVal sFileName As String, ByVal sSource As String, ByVal sDescription As String)
    How do I fix this?
    Wednesday, March 31, 2010 9:04 PM


  • Try changing "Excel.Application" in line 10 to just "Application". "Excel.Application" would work only if you have an "Imports Excel = Microsoft.Office.Interop.Excel" statement to create an "Excel" alias for the "Microsoft.Office.Interop.Excel" namespace. In your case, you just have an imports statement that brings the entire Microsoft.Office.Interop.Excel namespace into scope, without using an alias.

    Note that this forum is specifically for questions about using VSTO projects (the project templates that are available under the Office node of the New Project dialog box in Visual Studio) and related tools, not ASP.NET projects.

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, March 31, 2010 9:25 PM