Skip to content

Instantly share code, notes, and snippets.

@DexterPOSH
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterPOSH/af0e5615e17a241a7ee7 to your computer and use it in GitHub Desktop.
Save DexterPOSH/af0e5615e17a241a7ee7 to your computer and use it in GitHub Desktop.
$objWord = New-Object -ComObject word.application
$objWord.Visible = $True
$objDoc = $objWord.Documents.Open("C:\temp\test.docx")
$FindText = "document"
foreach ($docrange in $objDoc.Words)
{
if ($docrange.Text.Trim() -eq $FindText)
{
$docrange.highlightColorIndex = [Microsoft.Office.Interop.Word.WdColorIndex]::wdYellow
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment