Is there a way to get the enums in VBA?

前端 未结 8 1973
南旧
南旧 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:38

    No - there is no native way to do this. You'd need to fully parse all of the user code and read the type libraries of any loaded projects and finally determine what scope each reference was referring to.

    Enumerations can't be treated like reference types in VBA, and this due to the deep roots that VBA has in COM. Enums in VBA are more like aliases, and in fact, VBA doesn't even enforce type safety for them (again, because of COM interop - MIDL specs require that they are treated as a DWORD).

    If you really need to do this in VBA, a good workaround would be to create your own enumeration class and use that instead.

提交回复
热议问题