ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automation multiversion excel 2003-2007 (https://www.excelbanter.com/excel-programming/389287-automation-multiversion-excel-2003-2007-a.html)

bull73

Automation multiversion excel 2003-2007
 
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


Jim Cone

Automation multiversion excel 2003-2007
 

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"
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


bull73

Automation multiversion excel 2003-2007
 

Jim Cone wrote:
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"
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 ?


Jim Cone

Automation multiversion excel 2003-2007
 

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"
wrote in message Jim Cone wrote:
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"
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 ?


Jon Peltier

Automation multiversion excel 2003-2007
 
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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jim Cone" wrote in message
...

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"
wrote in message Jim Cone wrote:
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"
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 ?




patrick kilgore

Publisher Policies
 
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.


All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com