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
OpenFileDialog1.ShowDialog()
Dim intResult As Integer
strFilename = OpenFileDialog1.FileName
If strFilename = "" Then
Exit Sub
Else
'open the excel sheet selected by user
trFile.Workbooks.Open(Me.strFilename)
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!