Need to Change Font Type

Hello PowerShell Gurus,

I need your help in my script. I need to be able to edit the font type of a document to “MS PGothic” and then save it as PDF. The problem is it does not change all the fonts just save it as pdf. I am thinking perhap because it is in protected mode. Could you help me find out what is wrong with my code? Thanks in advance.


$folderpath = “C:\Users\codavar\Documents\CCIBS\Report\”
$word = New-Object -ComObject word.application
$word.visible = $False
$DisplayAlerts = $false

$fileTypes = “.doc”, ".docx"

Update-FormatData -path $fileTypes |

foreach-object {

$path = ($.fullname).substring(0,($.FullName).lastindexOf(“.”))

“Converting $path to pdf …”

$doc = $$_.fullname)


$Word.Selection.PageSetup.Orientation = 1

$Word.Selection.Font.Name = “MS PGothic”

$doc.saveas([ref] $path, [ref]$wdFormatPDF)




This is not a PS issue. It’s your use of the Word DOM.

You can easily figure this out by opening the doc, starting the Macro Recorder, do the steps in Word interactively, and review what the Macro Recorder did, and move that VBA code to your PS script.

If you don’t want to go that step, there are lots of examples all over the web on how to do this. For example:

How Can I Change the Font Name and Size for an Entire Word Document?

Powershell Script to change the font of word docs

Beginning with PowerShell and Word

Convert Word documents using PowerShell

This script converts Word compatible documents to a selected format utilizing the Word SaveAs function. Each file is converted by a single dedicated Word COM instance.The script converts either all documents in a single folder of a matching an include filter or a single file.
Download : Convert-WordDocument.ps1