473,289 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Trouble Working with Excel Versions

My application works with Excel to put together spreadsheets for
reporting purposes. It runs just fine on my box, but when I put it on
another one, it bombs.

Here is the relevant code:

Public Function ImportSis(ByVal strSisFile As String) As Boolean
If m_Excel Is Nothing Then
m_Excel = New Excel.Application
End If
m_Excel.Visible = True
Dim oSis As Excel.Workbook
oSis = m_Excel.Workbooks.Open(strSisFile)

At that point, I get a NullReferenceException, saying that oSis hasn't
been instantiated. This method, though, returns a new reference so
instantiation should be irrelevant. For grins, I did a NEW right before
on the oSis, but got the same error.

This code runs just fine on my development box, running Excel 2003. It
also runs on another box that has Excel 2002. It bombs when on a box
running Excel 2000. I originally had used the reference for "Microsoft
Excel 11.0 Object Library" but when I suspected I had a versioning
problem I removed that reference, grabbed an "Excel09.olb" file off of
someone else's box running Office 2000, and made a reference to THAT
instead. That didn't solve my problem, though, and I just now took
another look at it and it somehow got back to the 11.0 version; weird.

Long story; anyone have any suggestions? How can I correctly reference
an Excel 2000 library instead, and do I need to worry about detecting the
version of Excel to load maybe a different version of the library at
runtime?

I appreciate any help.

--
Michael
Nov 21 '05 #1
3 1959
This code works in office 2000 but not in 2003:

Dim oSis As Excel.Workbook = ExcelApplication.Workbooks.Add
oSis.Worksheets.Application.Cells(1, 1) = ...

I will be happy to know if there is a code that can work with both versions.

"Michael Kellogg" wrote:
My application works with Excel to put together spreadsheets for
reporting purposes. It runs just fine on my box, but when I put it on
another one, it bombs.

Here is the relevant code:

Public Function ImportSis(ByVal strSisFile As String) As Boolean
If m_Excel Is Nothing Then
m_Excel = New Excel.Application
End If
m_Excel.Visible = True
Dim oSis As Excel.Workbook
oSis = m_Excel.Workbooks.Open(strSisFile)

At that point, I get a NullReferenceException, saying that oSis hasn't
been instantiated. This method, though, returns a new reference so
instantiation should be irrelevant. For grins, I did a NEW right before
on the oSis, but got the same error.

This code runs just fine on my development box, running Excel 2003. It
also runs on another box that has Excel 2002. It bombs when on a box
running Excel 2000. I originally had used the reference for "Microsoft
Excel 11.0 Object Library" but when I suspected I had a versioning
problem I removed that reference, grabbed an "Excel09.olb" file off of
someone else's box running Office 2000, and made a reference to THAT
instead. That didn't solve my problem, though, and I just now took
another look at it and it somehow got back to the 11.0 version; weird.

Long story; anyone have any suggestions? How can I correctly reference
an Excel 2000 library instead, and do I need to worry about detecting the
version of Excel to load maybe a different version of the library at
runtime?

I appreciate any help.

--
Michael

Nov 21 '05 #2
On Mon, 24 Jan 2005 11:42:51 -0800, Michael Kellogg <mk******@WEDELIVERcc3.com> wrote:

¤ My application works with Excel to put together spreadsheets for
¤ reporting purposes. It runs just fine on my box, but when I put it on
¤ another one, it bombs.
¤
¤ Here is the relevant code:
¤
¤ Public Function ImportSis(ByVal strSisFile As String) As Boolean
¤ If m_Excel Is Nothing Then
¤ m_Excel = New Excel.Application
¤ End If
¤ m_Excel.Visible = True
¤ Dim oSis As Excel.Workbook
¤ oSis = m_Excel.Workbooks.Open(strSisFile)
¤
¤ At that point, I get a NullReferenceException, saying that oSis hasn't
¤ been instantiated. This method, though, returns a new reference so
¤ instantiation should be irrelevant. For grins, I did a NEW right before
¤ on the oSis, but got the same error.
¤
¤ This code runs just fine on my development box, running Excel 2003. It
¤ also runs on another box that has Excel 2002. It bombs when on a box
¤ running Excel 2000. I originally had used the reference for "Microsoft
¤ Excel 11.0 Object Library" but when I suspected I had a versioning
¤ problem I removed that reference, grabbed an "Excel09.olb" file off of
¤ someone else's box running Office 2000, and made a reference to THAT
¤ instead. That didn't solve my problem, though, and I just now took
¤ another look at it and it somehow got back to the 11.0 version; weird.
¤
¤ Long story; anyone have any suggestions? How can I correctly reference
¤ an Excel 2000 library instead, and do I need to worry about detecting the
¤ version of Excel to load maybe a different version of the library at
¤ runtime?
¤
¤ I appreciate any help.

If you have to support multiple versions, use late binding.

How To Use Visual Basic .NET for Binding for Office Automation Servers
http://support.microsoft.com/default...b;en-us;304661

In addition, when developing your application you need to seriously consider working with the lowest
supported version of Office.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #3
Paul Clement <Us***********************@swspectrum.com> wrote:
If you have to support multiple versions, use late binding.

How To Use Visual Basic .NET for Binding for Office Automation Servers
http://support.microsoft.com/default...b;en-us;304661

In addition, when developing your application you need to seriously
consider working with the lowest supported version of Office.


Excellent advice on both counts. I got roped into a higher version of
Excel on an earlier project which required XML features that only existed
in Excel 2003. But that application is only run by one person here, while
everyone else uses 2000.

Thanks for the help.

--
Michael Kellogg
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
6
by: Jeti [work] | last post by:
I have Office2003 installed, and trying to read excel file from C#. I made ExcelWrapper class, and it worked fine until new version of offide came! Now, when i'm trying to open workbook, i get an...
9
by: Brian Hanson | last post by:
Hi, I have an unusual problem that just showed its ugly head at a pretty bad time. I have an asp.net (VB) app that takes data from an Excel sheet and puts it into SQL Server. I get the data...
3
by: Boris Condarco | last post by:
Hi gurus, I'm using excel 2000 to show data that comes from datagrid. The problem is that for any reason the asp.net application maintains the excel open, even though, i do close it. Besides,...
11
by: BrianDH | last post by:
Hi Is there a way, in VB.Net, to write a windows based program that will use more than one version of Office (Excel)? Example: if office 2000 then else if office 2003 then. Is this possible? ...
3
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
2
by: rubikzube* | last post by:
I'm new to mysql and I was wondering if I could trouble some of you for help. I have a table in my database that may contain multiple versions of the same element as different rows. I wanted to...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.