Created
September 3, 2025 11:56
-
-
Save eugrus/3d1f996fc02bc1ba54d3309928522111 to your computer and use it in GitHub Desktop.
remove highlights & shading from the active document in Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$word = [Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application") | |
$doc = $word.ActiveDocument | |
if ($doc) { | |
# Clear highlights & shading | |
foreach ($r in $doc.StoryRanges) { | |
do { | |
$r.HighlightColorIndex = [Microsoft.Office.Interop.Word.WdColorIndex]::wdNoHighlight | |
$r.Shading.BackgroundPatternColor = [Microsoft.Office.Interop.Word.WdColor]::wdColorAutomatic | |
$r = $r.NextStoryRange | |
} while ($r) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment