I have an application that opens up Excel, reads some information, then closes Excel. I developed this application using Microsoft Office XP 2007. A few weeks ago, my company upgraded to Microsoft Office 2010. The applications still works fine, but I can not compile in VS 2008 anymore. I get the error message: "Error 3 'Application' is ambiguous in the namespace 'Microsoft.Office.Interop.Excel'." I have updated my COM reference to Microsoft Office 14.0 Object Library, but the same message appears. Here is some code I have used:

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

Public Class frmImportDoc
    Dim trFile As New Excel.Application   '<---- Application is 'Ambiguous' in the namespace
    Dim trSheet As New Excel.Worksheet    '<---- Application is 'Ambiguous' in the namespace

    Private Sub btnImportDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImportDoc.Click
        'open file window for user to select document
        Dim intResult As Integer
        strFilename = OpenFileDialog1.FileName
        If strFilename = "" Then
            Exit Sub
            'open the excel sheet selected by user

Obviously there is a bunch of stuff under this, but this shows where the errors are.

I am unable to fix a bug in the program because I can not even compile it without error. Any help is much appreciated! Thanks!

Try this:

Imports Excel = Microsoft.Office.Interop.Excel

Public Class frmImportDoc
    Dim trFile As Excel.Application

Or you can try removing and re-adding the reference.
Or you can simply ignore the Imports altogether and use the full name in the code.

I tried the code you posted, but the same thing happens. For the sake of testing, I tried using the full name and get a mess of other errors. I have removed and added references and tried compiling between actions but still, nothing works.

This is actually getting sort of frustrating. Personally, I don't like the new Office 2010, and this is just decorating the cake for me.

I appreciate your help. Thanks!

I found some more information regarding the removal and re-adding of the reference method I posted.

After you remove the reference from the project, you should also delete the auto-generated Excel interop assembly in the application's bin folder.
Then re-add the reference to the project.

i found that removing the refereence all together and my solution works with just the imports command. perhaps this version of VS does not need both reference and imports? it seems to be adding it twice when its in the reference and also has an imports. i did not try to use reference without imports