How to change the MS Word font type and size using PowerShell ?

Welcome Forums General PowerShell Q&A How to change the MS Word font type and size using PowerShell ?

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
6 months, 1 week ago.

  • Author
    Posts
  • #100335

    Participant
    Points: 52
    Rank: Member

    0

    Hi All,
    I've got the below PowerShell script for setting the default Outlook email signature: https://github.com/a118n/poweradmin/blob/master/Set-Outlook-Signature/Set-Outlook-Signature.ps1
    Now I wonder what's the command to set the font to be "Courier New" rather than the default Calibri font?

    I have already got the MS Word document template created by the designer in the shared folder and saved with all font as Courier New, but still failed to change the font type from the default Calibri as per Normal.Dot file.

    $MSWord = New-Object -com word.application
    $MSWord.Documents.Open("$LocalSignaturePath\$SignatureName.docx")
    $MSWord.Documents.Selection.Font.Name = 'Courier New'

    And I have tried the below combination as well:

    $MSWord.ActiveDocument.FontName = 'Courier New'
    $MSWord.ActiveDocument.Range.Font.Name = 'Courier New'
    $MSWord.ActiveDocument.Selection.Font.Name = 'Courier New'
    $MSWord.ActiveDocument.Text.Selection.Font= 'Courier New'
    $MSWord.ActiveDocument.Text.Selection.Font.Name = 'Courier New'
    $MSWord.ActiveDocument.Selection.Range.Font.Name = 'Courier New'
    $MSWord.ActiveDocument.Selection.Text.Font.Name = 'Courier New'

    But it does not recognize the "Name" as the property.

    Any help would be greatly appreciated.

  • #100339

    Participant
    Points: 144
    Helping Hand
    Rank: Participant
    • #100381

      Participant
      Points: 52
      Rank: Member

      Hi Olaf, that did not work.
      Hence it is posted here.

The topic ‘How to change the MS Word font type and size using PowerShell ?’ is closed to new replies.