+ Reply to Thread
Results 1 to 4 of 4

Return enum constant

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Question Return enum constant

    In Excel VBA we can use the WindowState enumeration to get the current state of a given window

    xlNormal = -4143
    xlMaximized = -4137
    xlMinimized = -4140

    When I ask for the WindowState like in
    Please Login or Register  to view this content.
    the answer comes as

    PERSONAL.XLSB = -4143
    Book1 = -4140

    Now the question - how could I receive the answer like:

    PERSONAL.XLSB = xlNormal
    Book1 = xlMinimized

    (without having to set up a select case)

    Grtz Bart

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Return enum constant

    Although you will mean something else. Without Select Case

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: Return enum constant

    Sorry to say so, but I think, you will have to do it yourself. The translation goes only one way.
    With windowstate there are just 3 constants (two mentioned above and -4137 for xlMaximized).
    So you are in good situation not dealing for instance with XlRgbColor enumeration - and it's 142 constants!

    How about using choose (I know, it's pretty close to Select Case):
    Please Login or Register  to view this content.
    Edit: pretty similar to above
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Return enum constant

    ThnX "Vraag en Antwoord" and "Kaper",

    You both provided neat and compact solutions to the missing of the "backwards enumeration".

    Indeed the number of enumeration constants can be quite large (as in XlRgbColor) so I think the challenge here is to construct a function to transform any enumerated property to a dictionary for further use...

    Grtz Bart

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [VBA] Enum question
    By lok1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2016, 01:49 PM
  2. You might need Enum values explained - try this
    By brynbaker in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-09-2013, 06:11 AM
  3. Enum: use same user-defined name in 2 Enum's
    By onidarbe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2013, 11:25 AM
  4. Enum for Strings
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2011, 08:56 PM
  5. Excel 2007 : #ENUM error
    By robinx1578 in forum Excel General
    Replies: 2
    Last Post: 09-21-2009, 05:35 AM
  6. Enum type variables
    By KC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-01-2006, 08:45 PM
  7. [SOLVED] Excel 97 Enum
    By Larry Dodd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-11-2005, 07:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1