Consulting

Results 1 to 6 of 6

Thread: Solved: Same Excel Constants Have Different Names??

  1. #1

    Solved: Same Excel Constants Have Different Names??

    For the following I have always used the constants as shown:

    Application.Calculation........ xlManual, xlAutomatic
    .HorizontalAlignment.......... xlCenter, xlLeft
    .VerticalAlignment.............. xlCenter, xlBottom

    But I?ve noticed that in Help they show expanded names like:

    xlCalculationManual, xlCalculationAutomatic
    xlHAlignCenter, xlHAlignLeft, etc.
    xlVAlignCenter, xlVAlignBottom, etc.

    It isn?t clear to me what the difference is (if any) or why they?ve changed the names.
    Is there any danger in continuing to use the shortened names?

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    I don't think so.

    What the constant is named is really sort of irrelavant, it just helpful.

    You could actually just replace the constants with the appropriate integer value.

  3. #3
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    I don't think there's any real danger in practice - but in theory xlAutomatic, say, could be given a new numeric value in a new release of Excel so that it would no longer be the same as xlCalculationAutomatic. It's good practice to use the 'correct' constants but I wouldn't lose any sleep over it.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  4. #4
    I assume from what you say that all the similar constants have the same numeric value. I tested some of them and they were indeed the same. I guess I just got the feeling that there must have been a reason for the change, and I couldn't help but wonder what it was and if it might have an impact on older code.

  5. #5
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    Microsoft has maintained the Constants so that all similar names have the same constant value BUT refer to different Constant groups eg.


    The above is the group constants for Xlcalculation note the [Automatic]

    Now for the same constant values -4105
    See below right image



    See above left.
    MS has maintained the same value even though they belong to different groups. Although I have found no real conflicting ones
    I would still stick to the Actual Const given for THAT GROUP, just in case. You can do this via having the intellisence turned on.
    Kind Regards,
    Ivan F Moala From the City of Sails

  6. #6
    Thanks, Gang! I think you are right about starting to use the newest versions.

Posting Permissions

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