Change the default font in word and outlook using intune

Paul McGeady 10 Reputation points
2024-04-04T14:09:24.63+00:00

Hi - now that Microsoft has changed the default to Aptos, i have a requirement to change it back for all users to Calibri in line with our corporate branding. Office templates have already been deployed via a sharepoint document library. The issue I have is for "new" documents. (e.g. start word, File - New... the default font is Aptos

I have tried to deploy a new Normal.dot file as a Win32 app using intune - thinking a pretty straight forward powershell command would copy a new normal.dot file

Copy-Item -Path "$PSScriptRoot\Normal.dotm" -Destination "$env:USERPROFILE\AppData\Roaming\Microsoft\Templates" -Force

it isnt working. Intune says its successful but the default font hasnt changed so I think the original normal.dot is still in use. Anybody know an easy way I can set all users default font to Calibri in Word and outlook from InTune ?

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
736 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,665 questions
0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. John Korchok 5,156 Reputation points
    2024-04-04T15:53:27.1833333+00:00

    Microsoft templates like Normal.dotm do not directly refer to Calibri. Instead, they refer to the major and minor theme fonts. So instead of trying to replace Normal.dotm, replace the font theme that is attached to Normal.dotm.

    1 person found this answer helpful.

  2. Crystal-MSFT 45,656 Reputation points Microsoft Vendor
    2024-04-05T01:30:54.8766667+00:00

    @Paul McGeady, Thanks for posting in Q&A. In the command, I notice there's some environment variables which may be different when the command is running with different credentials. I guess the issue can be with the user we run the command.

    Please check what we set for "Install behavior". If we set it to System, then the file maybe under system account. if we set it to User, then the file will be copied to the logging user when apply the app.

    https://video2.skills-academy.com/en-us/mem/intune/apps/apps-win32-add#step-2-program

    Hope the above information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Dirk Baltissen 0 Reputation points
    2024-06-06T19:10:55.16+00:00

    Good evening,

    To change the default font in Word, i have written a remediation script to be used in Intune that adjusts and saves the 'Normal' style.

    The script first checks if Word is installed.
    Then it checks the OS language (in my case, I had to change the style from 'Normal' to 'Standaard' because we use a Dutch OS).
    Next, it checks if Word is running; if not, the font is adjusted.
    If Word is running, the script stops. However, with Proactive Remediation, you can schedule it to run every X days or every X hours if you want.

    If you want to use the scripts, please make sure they run using the logged-on credentials!

    You can adjust more styles; for this, you need to find the relevant styles first.
    I have also included a script for this.

    Hopefully, this will be useful to you!

    Detection:

    # Variables
    $WordEXE = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
    $systemLocale = Get-WinSystemLocale
    $desiredFontName = "Arial"    # Change this to the desired font
    $desiredFontSize = 10         # Change this to the desired size
    # Check if Word is installed
    if (test-path -Path "$WordEXE") {
        Write-Host "Word is installed."
        # Check if current system language is English (US)
        if ($systemLocale -eq "en-US") {
            Write-Host "The system language is English."
            # Check if Word is running
            $wordProcesses = Get-Process | Where-Object { $_.ProcessName -eq "WINWORD" }
            if ($wordProcesses.Count -gt 0) {
                Write-Host "Word is running."
                Exit 0
            } else {
                Write-Host "Checking if the correct font is set."
                # Start Word application (hidden)
                $word = New-Object -ComObject Word.Application
                $word.Visible = $false  # Ensure Word is invisible
                # Create a new document
                try {
                    $document = $word.Documents.Add()
                    if ($null -eq $document) {
                        throw "The new document could not be created."
                    } else {
                        Write-Host "New document created."
                    }
                } catch {
                    Write-Host "Error creating new document: $_"
                    # Close Word application
                    $word.Quit()
                    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
                    exit
                }
                # Check if the current default font differs from the desired font
                $currentFontName = $document.Styles.Item("Normal").Font.Name
                $currentFontSize = $document.Styles.Item("Normal").Font.Size
                if ($currentFontName -ne $desiredFontName -or $currentFontSize -ne $desiredFontSize) {
                    Write-Host "The font is incorrect."
                    
                    # Try to close the document without saving, with error handling
                    try {
                        $document.Close($false)
                        Write-Host "Document closed."
                    } catch {
                        Write-Host "Error closing the document: $_"
                    }
                    
                    # Close Word application
                    try {
                        $word.Quit()
                        Write-Host "Word closed."
                    } catch {
                        Write-Host "Error closing Word: $_"
                    }
                    # 2nd Write-Host for visibility in Intune 
                    Write-Host "The font is incorrect, proceeding to Remediation"
                    Exit 1
                } else {
                    Write-Host "The font is correctly set."
                    # Try to close the document without saving, with error handling
                    try {
                        $document.Close($false)
                        Write-Host "Document closed."
                    } catch {
                        Write-Host "Error closing the document: $_"
                    }
                    # Close Word application
                    try {
                        $word.Quit()
                        Write-Host "Word closed."
                    } catch {
                        Write-Host "Error closing Word: $_"
                    }
                    # Clean up
                    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($document) | Out-Null
                    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
                    # 2nd Write-Host for visibility in Intune
                    Write-Host "The font is correctly set."
                    Exit 0
                }
            }
        } else {
            Write-Host "The system language is not English."
            Exit 0
        }
    } else {
        Write-Host "Word is not installed."
        Exit 0
    }
    
    
    

    Remediation:

    # Variables
    $desiredFontName = "Arial"    # Change this to the desired font
    $desiredFontSize = 10         # Change this to the desired size
    # Check if Word is running
    $wordProcesses = Get-Process | Where-Object { $_.ProcessName -eq "WINWORD" }
    if ($wordProcesses.Count -gt 0) {
        Write-Host "Word is running."
    } else {
        Write-Host "Checking if the correct font is set."
        # Start Word application (hidden)
        $word = New-Object -ComObject Word.Application
        $word.Visible = $false  # Ensure Word is invisible
        # Create a new document
        try {
            $document = $word.Documents.Add()
            if ($null -eq $document) {
                throw "The new document could not be created."
            } else {
                Write-Host "New document created."
            }
        } catch {
            Write-Host "Error creating new document: $_"
            # Close Word application
            $word.Quit()
            [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
            exit
        }
        # Check if the current default font differs from the desired font
        $currentFontName = $document.Styles.Item("Normal").Font.Name
        $currentFontSize = $document.Styles.Item("Normal").Font.Size
        if ($currentFontName -ne $desiredFontName -or $currentFontSize -ne $desiredFontSize) {
            try {
                # Get the 'Normal' style of the new document
                $normalStyle = $document.Styles.Item("Normal")
                if ($null -eq $normalStyle) {
                    throw "The 'Normal' style could not be found in the document."
                } else {
                    Write-Host "Normal style found in the document."
                }
                # Change the font and size in the 'Normal' style
                $normalStyle.Font.Name = $desiredFontName
                $normalStyle.Font.Size = $desiredFontSize
                Write-Host "The default font has been updated in the document."
                # Open NormalTemplate as a document
                $normalTemplatePath = $word.NormalTemplate.FullName
                $normalTemplateDoc = $word.Documents.Open($normalTemplatePath)
                if ($null -eq $normalTemplateDoc) {
                    throw "The normal template document could not be opened."
                } else {
                    Write-Host "NormalTemplate document opened."
                }
                # Get the 'Normal' style of the NormalTemplate document
                $normalTemplateStyle = $normalTemplateDoc.Styles.Item("Normal")
                if ($null -eq $normalTemplateStyle) {
                    throw "The 'Normal' style could not be found in the NormalTemplate document."
                } else {
                    Write-Host "Normal style found in the NormalTemplate document."
                }
                # Change the font and size in the 'Normal' style of the NormalTemplate document
                $normalTemplateStyle.Font.Name = $desiredFontName
                $normalTemplateStyle.Font.Size = $desiredFontSize
                Write-Host "The default font has been updated in the NormalTemplate document."
                # Save the NormalTemplate document
                $normalTemplateDoc.Save()
                Write-Host "The default font has been saved in the NormalTemplate document."
                # Close the NormalTemplate document
                $normalTemplateDoc.Close($false)
            } catch {
                Write-Host "An error occurred while updating the font: $_"
            }
        } else {
            Write-Host "The current default font is already set to the desired font. No further action needed."
        }
        
        # Try to close the document without saving, with error handling
        try {
            $document.Close($false)
            Write-Host "Document closed."
        } catch {
            Write-Host "Error closing the document: $_"
        }
        
        # Close Word application
        try {
            $word.Quit()
            Write-Host "Word closed."
        } catch {
            Write-Host "Error closing Word: $_"
        }
        # Clean up
        [System.Runtime.Interopservices.Marshal]::ReleaseComObject($document) | Out-Null
        [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
    }
    
    
    

    Search and list Styles:

    # Start a new Word application
    $word = New-Object -ComObject Word.Application
    $word.Visible = $false  # Ensure Word is invisible
    # Create a new document
    try {
        $document = $word.Documents.Add()
        if ($null -eq $document) {
            throw "The new document could not be created."
        } else {
            Write-Host "New document created."
        }
    } catch {
        Write-Host "Error creating new document: $_"
        # Close Word application
        $word.Quit()
        [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
        exit
    }
    # Print a list of all styles in the document
    try {
        Write-Host "Available styles in the document:"
        $styles = $document.Styles
        foreach ($style in $styles) {
            Write-Host $style.NameLocal
        }
    } catch {
        Write-Host "Error obtaining available styles: $_"
    }
    # Try to close the document without saving, with error handling
    try {
        $document.Close($false)
        Write-Host "Document closed."
    } catch {
        Write-Host "Error closing the document: $_"
    }
    # Close Word application
    try {
        $word.Quit()
        Write-Host "Word closed."
    } catch {
        Write-Host "Error closing Word: $_"
    }
    # Clean up
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($document) | Out-Null
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($word) | Out-Null
    
    
    0 comments No comments