Home All Groups Group Topic Archive Search About

Excel 2003 - problem using from .Net

Author
14 Feb 2007 1:16 PM
Peter A
Visual Studio 2005. The following code was working OK with Excel 2007:

Dim xlApp As New Excel.Application
Dim wb As Excel.Workbook
If Not File.Exists(AnionSpreadsheetName) Then
    MsgBox("File not found: " & AnionSpreadsheetName)
    Exit Sub
End If
wb = xlApp.Workbooks.Open(AnionSpreadsheetName)

Then, because my client uses Excel 2003 I uninstalled Office 2007 and
re-installed Office 2003. Now, on the last line (the call to Open) I get
this error:

Unable to cast COM object of type
'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
'Microsoft.Office.Interop.Excel._Application'. This operation failed
because the QueryInterface call on the COM component for the interface
with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the
following error:  could not be found. (Exception from HRESULT:
0x80030002 (STG_E_FILENOTFOUND)).

The file does exist and can be opened manually in Excel 2003, so I am at
a loss.

Thanks in advance,

--
Peter Aitken

Author
14 Feb 2007 5:34 PM
Paul Clement
On Wed, 14 Feb 2007 08:16:13 -0500, Peter A <pait***@CRAP.nc.rr.com> wrote:

¤ Visual Studio 2005. The following code was working OK with Excel 2007:
¤
¤ Dim xlApp As New Excel.Application
¤ Dim wb As Excel.Workbook
¤ If Not File.Exists(AnionSpreadsheetName) Then
¤     MsgBox("File not found: " & AnionSpreadsheetName)
¤     Exit Sub
¤ End If
¤ wb = xlApp.Workbooks.Open(AnionSpreadsheetName)
¤
¤ Then, because my client uses Excel 2003 I uninstalled Office 2007 and
¤ re-installed Office 2003. Now, on the last line (the call to Open) I get
¤ this error:
¤
¤ Unable to cast COM object of type
¤ 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
¤ 'Microsoft.Office.Interop.Excel._Application'. This operation failed
¤ because the QueryInterface call on the COM component for the interface
¤ with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the
¤ following error:  could not be found. (Exception from HRESULT:
¤ 0x80030002 (STG_E_FILENOTFOUND)).
¤
¤ The file does exist and can be opened manually in Excel 2003, so I am at
¤ a loss.

You're going to have to remove the reference to Excel 2007 from your project and then add the
reference for Excel 2003. I would also delete the Excel interop assembly from your bin folder before
adding the Excel 2003 reference.


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
14 Feb 2007 5:35 PM
Norman Yuan
You app is compiled against Excel2007 PIA. PIA only useful when the
application, from which it is derived, is present. Since you have
uninstalled Excel2007, your app stops working as it should do.

You need to recompile your app against correct targeting version of Excel.

Note, if your app is targeting older version of MS Office app, it may (or
most likely) still work on a computer with newer version MS office app
installed. But not the other way around, in most cases.

Show quote
"Peter A" <pait***@CRAP.nc.rr.com> wrote in message
news:MPG.203cd5a5bc04d56d98968d@msnews.microsoft.com...
> Visual Studio 2005. The following code was working OK with Excel 2007:
>
> Dim xlApp As New Excel.Application
> Dim wb As Excel.Workbook
> If Not File.Exists(AnionSpreadsheetName) Then
>    MsgBox("File not found: " & AnionSpreadsheetName)
>    Exit Sub
> End If
> wb = xlApp.Workbooks.Open(AnionSpreadsheetName)
>
> Then, because my client uses Excel 2003 I uninstalled Office 2007 and
> re-installed Office 2003. Now, on the last line (the call to Open) I get
> this error:
>
> Unable to cast COM object of type
> 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
> 'Microsoft.Office.Interop.Excel._Application'. This operation failed
> because the QueryInterface call on the COM component for the interface
> with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the
> following error:  could not be found. (Exception from HRESULT:
> 0x80030002 (STG_E_FILENOTFOUND)).
>
> The file does exist and can be opened manually in Excel 2003, so I am at
> a loss.
>
> Thanks in advance,
>
> --
> Peter Aitken

AddThis Social Bookmark Button