Author Posts

May 4, 2016 at 8:50 am

I have a script where I am replacing a bookmark in a word document with text from a xml.

I have hard coded a few words into the word document via the bookmark properties. I am trying to turn the font of the strings I hardcoded into the document into bold and increase the font size

StigData is predefined earlier in my script... The script works fine its just not bolding the font.
$template = "Template.docx"
$wd = New-Object –comobject Word.Application

foreach ($stigDataItem in $stigData)
$title = $stigDataItem.title
$check = $'check-content'
$ft = $

$doc.Bookmarks.Item("AllStigInfo").Range.Text ="FixText" + "`r`n" + $ft + "`r`n" +"`r`n"
$doc.Bookmarks.Item("AllStigInfo").Range.Text ="Check Content" + "`r`n" + $check + "`r`n"
$doc.Bookmarks.Item("AllStigInfo").Range.Text =$title + "`r`n"


$selection = $wd.selection
$selection.Font.Bold = $True
$stringcheck = "Check Content"

Remove-Variable wd

I attempted to select the words I need to replace and replace it with a bold font with the section:
$selection = $wd.selection
$selection.Font.Bold = $True
$stringcheck = "Check Content"

However that just added a bold word to the document.

I am trying to bold everywhere that says FixText, Check Content, and $title. Also making $title a bigger font.

Also tried referring to but it didn't work out for me.