<# .SYNOPSIS Get the constants for a COM Object .DESCRIPTION This function returns the names and values of the constants for a COM Object .PARAMETER oCOM A COMObject .EXAMPLE Get the constants for Outlook $outlook = new-object -ComObject Outlook.application $oConstants = Get-ComConstants $outlook .EXAMPLE Get the Constants for Excel # create Excel object $xl = New-Object -ComObject Excel.Application $XLConstants = Get-ComConstants $xl #Get the value for constant $XLConstants.rgbAliceBlue.value__ .EXAMPLE Get the Constants for Excel, show results in Gridview, selected value goes to clipboard # create Excel object $xl = New-Object -ComObject Excel.Application $XLConstants = Get-ComConstants $xl $List= $XLConstants | Get-Member -m Properties | Foreach {[PSCustomObject]@{Constant = $_.Name;Value= ($XLConstants.[string]$_.name).value__}} $List|ogv -title "Pick a Constant" -PassThru | select -ExpandProperty value | clip .NOTES Alan Kaplan 12/25/16 This is a generalization of the code by Shay Levy posted at http://www.powershellmagazine.com/2013/03/20/pstip-working-with-excel-constants/ I have only tested it with office applications You should note that getting the list of constants can take a long time. You are better off getting the value and using it directly in the code. Also, remember to marshall the COM in the main code. .LINK www.akaplan.com/blog #> Function Get-ComConstants { [CmdletBinding()] [OutputType([Object])] Param( [Parameter(Mandatory=$true)] [object][ref]$oCom ) $retval = New-Object -TypeName psobject $oCom.GetType().Assembly.GetExportedTypes() | Where-Object {$_.IsEnum} | ForEach-Object { # create properties from enum values $enum = $_ $enum.GetEnumNames() | ForEach-Object { $retval | Add-Member -MemberType NoteProperty -Name $_ -Value $enum::($_) } } $retval }