Skip to content

Instantly share code, notes, and snippets.

@eugrus
Created January 26, 2026 09:20
Show Gist options
  • Select an option

  • Save eugrus/405efb77f37db2e628d2bf5677980e38 to your computer and use it in GitHub Desktop.

Select an option

Save eugrus/405efb77f37db2e628d2bf5677980e38 to your computer and use it in GitHub Desktop.
reformat built-in Word heading styles
$word = [Runtime.InteropServices.Marshal]::GetActiveObject("Word.Application")
$doc = $word.ActiveDocument
$headingStyles = 1..9 | ForEach-Object { -1 * $_ } # built-in Word heading styles (wdStyleHeading1 = -1 … wdStyleHeading9 = -9)
foreach ($styleId in $headingStyles) {
$style = $doc.Styles.Item($styleId)
$style.Font.Name = "Arial"
$style.Font.Size = 11
$style.Font.Color = 0 # wdColorBlack
$style.ParagraphFormat.LineSpacingRule = 3 # wdLineSpace1pt5
$style.ParagraphFormat.SpaceBefore = 0
$style.ParagraphFormat.SpaceAfter = 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment