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