Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    New York, New York, Lebanon
    Thanked 1 Time in 1 Post

    Conditional Compilation (Excel 97 and >)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Loungers

    OK what am I supposed to do when my users ask me to write backward compatible code?

    I have the following situation:

    We are using Excel 97 and soon to migrate to Excel 2000. Hurray!!! But we are still supposed to support both versions. One of my applications have a very short menu, only 3 items, and I am afraid that when Adaptive Menus come into play this menu will disappear and become a single item. But in Excel 97 the compiler does not understand the following line:

    <font color=red> bAdaptingMenus = Application.CommandBars.AdaptiveMenus </font color=red>

    So I used
    <font color=blue> #If iAppVersion >= 9 Then
    bAdaptingMenus = Application.CommandBars.AdaptiveMenus
    #End If
    </font color=blue>

    So now what, Excel compiles the lines if the iAppVersion is Excel 2000 or higher?

    Anyone has used this before? BTW the OLH has more info that the MSKB, does that say something?

    Thanks in Adacnce

    Wassim <img src=/S/compute.gif border=0 alt=compute width=40 height=20>
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    San Jose, California, USA
    Thanked 0 Times in 0 Posts

    Re: Conditional Compilation (Excel 97 and >)

    I too struggle with having to make my projects work with both xl97 and xl2000. I haven't used conditional compilation to solve the problem but I like your solution. I have found that if I use what works in xl97 then I'm *usually* safe with xl2000 as that's the least common denominator.Yes I lost some functionality but can usually work around. I do base a few things off of the Excel version number as you're doing but try to use code that works in both versions. I too add my own menu to the menu bar but have the adaptive menus turned off (they're so irritating and confusing to beginners) and didn't think about others using my tools who do not have this turned off. Thanks for the idea.

    For your particular problem though I'd just keep what you have or you can also do the old 'on error resume next' to ignore the error that would be generated in xl97. I think your solution is better as it's more obvious in the code why you're doing the #IF statement.

    Having to support multiple versions of Excel has almost doubled the schedule for release of my tool so I can sympathize with you as none of the problems I've found are documented. It's pure trial and error. I've heard my tools don't work in xl2002 (Office XP) so I installed Office XP on a separate PC to test it out. Is there no end to this madness!!! <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    Deb <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Weert, Limburg, Netherlands
    Thanked 0 Times in 0 Posts

    Re: Conditional Compilation (Excel 97 and >)

    I have read, that when you put the offending (for XL97) function or code into a separate function, it will not generate compile errors as long as you avoid that entire function to be called by the incompatible version:

    If iVersion>8 then
    End If

    Function Isadaptive() as Boolean
    IsAdaptive = Application.CommandBars.AdaptiveMenus
    End Function
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts