PowerTip: Use PowerShell ISE for Standard Enumerations


Summary: Use the Windows PowerShell ISE to use enumeration values.

Hey, Scripting Guy! Question How can I use the Windows PowerShell ISE to use the standard enumeration types to write a
           Word automation script?

Hey, Scripting Guy! Answer Cast the string as a type, and store the returned value in a variable. Each enumeration value
           will be available as a static property. Here is an example:

$HeaderFooterIndex = "microsoft.office.interop.word.WdHeaderFooterIndex" -as [type]

$HeaderFooterIndex::wdHeaderFooterFirstPage

Comments (1)

  1. christoph says:

    If I want to use a lot of different enumerations, is it someway possible to store "Microsoft.Office.Interop.Word" in a variable and select the enumerations, e.g. like

    $WordEnum.WdHeaderFooterIndex::wdHeaderFooterFirstPage ?

Skip to main content