views:

95

answers:

1

I have a project which opens a simple Excel file and populates it. It was working fine until this morning, when it has suddenly started giving me the error above: 'Application' is ambiguous in the namespace 'Microsoft.Office.Interop.Excel'.

I haven't changed any project references, or anything within the file itself. The references include Microsoft.Office.Interop.Excel. The imports statement is there: imports Microsoft.Office.Interop

The object declaration is also complete: Dim xl As Microsoft.Office.Interop.Excel.Application which is the line that's giving me the error!

I've tried googling this error, and the only response is that I need to declare xl as Microsoft.Office.Interop.Excel.Application.

The fact that I hadn't changed anything within the project nor the code tells me this is a corruption in Visual Studio 2008. However, cleaning and rebuilding the project, rebooting Windows, and restarting VS has no effect.

Any ideas?

+1  A: 

I don't think you should have the line as Imports Microsoft.Office.Interop. Either use

Imports Excel = Microsoft.Office.Interop.Excel

And then use it as:

Dim xl As Excel.Application

Or remove the Imports all together and use the full name everywhere, as:

Dim xl As Microsoft.Office.Interop.Excel.Application
ho1