Search notes:

Microsoft.Office.Interop.… : determine enum values

The values of a VBA enumeration can be determined in PowerShell by casting the (interop-) name of the enum into a System.RuntimeType type and then appliying reflection on the type to get the values.
The following example tries to demonstrate a few usages.
First, we need to load the assembly that provides an interop, for example Microsoft.Office.Interop.Excel:
$null = [Reflection.Assembly]::LoadWithPartialname('Microsoft.Office.Interop.Excel')
After loading the the interop, we cast it into a system.RuntimeType using the type accelerator [type]:
$xlBordersIndexEnum = 'Microsoft.Office.Interop.Excel.xlBordersIndex' -as [type]
Now, we're ready to print the value of a given entry in the enum, for example xlEdgeBottom:
write-host $xlBordersIndexEnum::xlEdgeBottom.value__
The following foreach statement iterates over each entry in the enum and prints its name and value:
foreach ($fieldInfo in $xlBordersIndexEnum.DeclaredFields) {
   if ($fieldInfo.name -ne 'value__') {
      '  {0,-20} {1,2} ' -f $fieldInfo.name, $xlBordersIndexEnum.GetDeclaredField($fieldInfo.name).GetRawConstantValue()
   }
}
The names of the enum can also be found using the GetNames() method of System.Enum:
[enum]::GetNames($xlBordersIndexEnum)

See also

The Microsoft.Office.Interop.….Constants enum contains the values for an Office's application global values.

Index