Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Help! Problem Referencing Excel 2003 in VB.NET

I am using Visual Studio 2008 Express Edition to develop some VB.NET
code that manipulates Excel files. I am developing on a Vista/Excel
2007 machine, but I need the code to work on an XP/2003 machine as
well.

I initially set a reference to the Microsoft Excel 12.0 Object Library
and imported the Microsoft.Office.Interop.Excel namespace. This works
great on the VIsta/Excel 2007 machine, but it does not work on 2003,
which needs the 11.0 library. I get an error that says "Unhandled
Exception . . . Could not file or assembly
'Microsoft.Office.Interop.Excel, Version 12.0.0.0 . . . The system
cannot find the file specified."

I searched through the other references I could find. I found nothing
for 11.0, but there was an Excel 5.0 Object Library. When I add this
and remove the Excel 12 library reference, it no longer works on
Vista.

What can I do to make this work on both Excel 2003 and 2007 without
having to compile on a machine with 2003?

Thanks, Alan



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Help! Problem Referencing Excel 2003 in VB.NET

I changed the reference to Excel 5.0 only and now only Import Excel.
I changed starting an instance of Excel to:

ExcelApp = CreateObject("Excel.Application")

The following code cannot open the workbook:

If FileExists(PathName) Then
MetaWB = ExcelApp.Workbooks.Open(PathName)

It finds that the file exists, but then the workbook cannot be opened:

A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Any ideas?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel (2003) crashes when referencing to external workbook in freezeframe dmkAlex Excel Worksheet Functions 0 November 27th 09 03:25 PM
Referencing Comments in Excel 2003 Alan Excel Discussion (Misc queries) 1 October 21st 09 12:09 PM
Excel 2003 - Referencing data in a table to use in formulas Rocketman Excel Worksheet Functions 8 February 28th 08 11:07 AM
Excel 2003 Referencing multiple worksheets EdGarrett Excel Discussion (Misc queries) 3 January 31st 08 02:48 PM
Excel 2003 Referencing multiple workbooks via single variable BBohannon Excel Worksheet Functions 0 April 20th 05 08:32 PM


All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"