ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A program running on different Excel Versions (https://www.excelbanter.com/excel-programming/320806-program-running-different-excel-versions.html)

Ian Stanborough

A program running on different Excel Versions
 
I have a program written on Excel 2003 and when i tried to run it on Excel
97, it would not compile correctly using the visual basic editor. I could
not find a command to differentiate between the two versions of EXCEL. I
wanted a command such that the appropriate code would be compiled for the
machine that i was on

#if EXCEL 2003 then
.....code
#else
#if EXCEL 97
... code
#end
# end


any suggestions?



Tom Ogilvy

A program running on different Excel Versions
 
The usual source of this problem is that you have used features in VBA that
are not supported in xl97. For example, for the sort function, there are
additional options introduced in xl2002/3 that xl97 does not recognize. The
only solution is to compile the code, have the compiler highlight the area,
fix the problem. Repeat until you get a good compile.

In the future you should do all your development on the lowest version of
excel.

If you want to go with compiler directives, you can do

#if vba6 then
....code
#else
... code
# end

xl2000 and above used VBA6. xl97 used vba5, but the compiler constants vba6
was only defined in vba6. So if the constant is defined, you are in xl2000
or later, otherwise xl97 or earlier.

You still have to write the correct code for each version.

Unless there is a special feature you must have when operating in the later
version, it is easier to develop in xl97 (or the lowest version that will
use the code).

If you haven't gotten that far and the problem is a references problem
(unknown library), then you need to go into Tools=References and fix the
bad references (shown as MISSING).


--
Regards,
Tom Ogilvy


"Ian Stanborough" wrote in message
...
I have a program written on Excel 2003 and when i tried to run it on Excel
97, it would not compile correctly using the visual basic editor. I

could
not find a command to differentiate between the two versions of EXCEL. I
wanted a command such that the appropriate code would be compiled for the
machine that i was on

#if EXCEL 2003 then
....code
#else
#if EXCEL 97
... code
#end
# end


any suggestions?





Fredrik Wahlgren

A program running on different Excel Versions
 

"Ian Stanborough" wrote in message
...
I have a program written on Excel 2003 and when i tried to run it on Excel
97, it would not compile correctly using the visual basic editor. I

could
not find a command to differentiate between the two versions of EXCEL. I
wanted a command such that the appropriate code would be compiled for the
machine that i was on

#if EXCEL 2003 then
....code
#else
#if EXCEL 97
... code
#end
# end


any suggestions?



What language do you use?

/Fredrik



Ian Stanborough

A program running on different Excel Versions
 

thank you Tom

Problem Solved


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 04:40 AM.

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