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?
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
Removing and re-adding the reference solved this issue.
Experienced the same problem and was able to identify the issue and resolve (note: my issue was with Outlook but same error occurred when using Excel):
After doing this the code "Dim olObject as Outlook.Application" no longer had the 'Application' is ambiguous in the namespace 'Microsoft.Office.Interop.Outlook.
The same method worked to resolve Excel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With