Automation multiversion excel 2003-2007

B

bull73

Hi lads.
I use simple excel automation im my c# 2.0 app.
I do it like in MS samples ,add reference to excel com libraries
,createobject ,etc and transfer DataTable to Excel.
But as far as I can see they changed object model in excel
2007 ,so i can't run my app on the PC with excel 2007 installed .
Of course I can change refernce to libraries and make small changes to
the
export functions ,but the modified version will not work on old 2003
excel
PC's
Can you help me with this problem ?
I wanna run my app on both versions
 
J

Jim Cone

Use two sets of code.
Check the application version and run the appropriate code.
Be aware that some XL 2003 code will not work on earlier XL versions.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"bull73" <[email protected]>
wrote in message
Hi lads.
I use simple excel automation in my c# 2.0 app.
I do it like the MS samples, add reference to excel com libraries,
createobject, etc and transfer DataTable to Excel.
But as far as I can see they changed object model in excel
2007, so i can't run my app on the PC with excel 2007 installed.
Of course I can change refernce to libraries and make small changes to
the export functions, but the modified version will not work on old
2003 excel PC's
Can you help me with this problem ?
I want to run my app on both versions
 
B

bull73

Jim said:
Use two sets of code.
Check the application version and run the appropriate code.
Be aware that some XL 2003 code will not work on earlier XL versions.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"bull73" <[email protected]>
wrote in message
Hi lads.
I use simple excel automation in my c# 2.0 app.
I do it like the MS samples, add reference to excel com libraries,
createobject, etc and transfer DataTable to Excel.
But as far as I can see they changed object model in excel
2007, so i can't run my app on the PC with excel 2007 installed.
Of course I can change refernce to libraries and make small changes to
the export functions, but the modified version will not work on old
2003 excel PC's
Can you help me with this problem ?
I want to run my app on both versions


Thanks a lot ,do you have some sapmle ?
 
J

Jim Cone

C# is a foreign language to me, so I am speaking about Excel VBA code only.
(this is not a C# newsgroup)

Assuming you have an object reference to Excel of objAppXL...
'Val is a VBA function that returns the number contained in a string
' as a numeric value of appropriate type
'Version is a string property that returns the application version.
'--
x = Val(objAppXL.Version)
If x < 12 Then
'run xl2003 code
Else
'run xl2007 code
End If
'--
If run from an Office application, you would want the xl2003 code
and the xl2007 code in separate modules to avoid compile problems.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


bull73 said:
Use two sets of code.
Check the application version and run the appropriate code.
Be aware that some XL 2003 code will not work on earlier XL versions.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"bull73" <[email protected]>
wrote in message
Hi lads.
I use simple excel automation in my c# 2.0 app.
I do it like the MS samples, add reference to excel com libraries,
createobject, etc and transfer DataTable to Excel.
But as far as I can see they changed object model in excel
2007, so i can't run my app on the PC with excel 2007 installed.
Of course I can change refernce to libraries and make small changes to
the export functions, but the modified version will not work on old
2003 excel PC's
Can you help me with this problem ?
I want to run my app on both versions


Thanks a lot ,do you have some sapmle ?
 
J

Jon Peltier

IMO, you'd want the 2003 and 2007 code in two separate add-ins. Seemingly
more work, but probably easier in the long run.

- Jon
 
P

patrick kilgore

Bear in mind that when you install office 2007, a publisher policy in the golbal assembly cache will prevent you from using the 2003 primary interop assemblies at runtime. You'll have to circumvent that in some way, or you'll get compatability warnings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top