Is there a way to get the enums in VBA?

前端 未结 8 1958
南旧
南旧 2020-12-06 07:51

Is there a way to get the enums in VBA? Something like this example for C#, but for VBA?

using System;

class EnumsExampleZ
{
    private enum SiteNames
             


        
8条回答
  •  一整个雨季
    2020-12-06 08:36

    Public Enum col: [____]: cPath: cFile: cType: End Enum 
    Public Const colNames$ = "Path: cFile: cType"
    

    Not directly an answer and might look pretty ugly, but I thought it might be useful to others.
    In an old project I wanted to access columns with Enum (for example row(, col.cType) = 1).
    I changed the column location, name, use, etc. pretty often, but with this lazy approach I could just rearrange the Enum and then copy paste the change in the string constant, and get the table headers:

    Range("A1:C1").Value2 = Split(colNames, ": c")
    

    Names starting with _ are hidden by default, so [____] is used for padding and to avoid "cPath = 1"

提交回复
热议问题