Forum Discussion
Rambo363636
Jun 28, 2024Brass Contributor
Need a powershell script to change the default font from Aptos to Verdana in powerpoint
Hi Champs, Does anyone could provide a powershell script to change the default font from Aptos to Verdana in powerpoint please. We are in a intune environment. I want to push it to all the devic...
DTB
Jul 03, 2024Iron Contributor
First, create a PowerShell script that changes the default font in PowerPoint. This script will modify the PowerPoint template to use Verdana instead of Aptos.
# Define the path to the PowerPoint template (this may vary based on the Office version and installation)
$templatePath = "$env:APPDATA\Microsoft\Templates\Normal.potx"
# Check if the template file exists
if (Test-Path -Path $templatePath) {
# Load PowerPoint COM object
$powerPoint = New-Object -ComObject PowerPoint.Application
$powerPoint.Visible = $true
# Open the template
$presentation = $powerPoint.Presentations.Open($templatePath, [System::Type]::Missing, [System::Type]::Missing, [System::Type]::Missing)
# Change the default font in the master slides
foreach ($slide in $presentation.Designs) {
foreach ($slideMaster in $slide.SlideMaster.CustomLayouts) {
foreach ($shape in $slideMaster.Shapes) {
if ($shape.TextFrame.HasText) {
$shape.TextFrame.TextRange.Font.Name = "Verdana"
}
}
}
}
# Save the changes
$presentation.SaveAs($templatePath)
# Close the presentation and PowerPoint
$presentation.Close()
$powerPoint.Quit()
# Release COM objects
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($slideMaster) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($presentation) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($powerPoint) | Out-Null
Write-Output "Default font in PowerPoint template has been changed to Verdana."
} else {
Write-Error "PowerPoint template not found at path: $templatePath"
}
Ensure the script is thoroughly tested in a controlled environment before deploying it broadly.
If you have any further questions or need additional assistance, feel free to ask.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
# Define the path to the PowerPoint template (this may vary based on the Office version and installation)
$templatePath = "$env:APPDATA\Microsoft\Templates\Normal.potx"
# Check if the template file exists
if (Test-Path -Path $templatePath) {
# Load PowerPoint COM object
$powerPoint = New-Object -ComObject PowerPoint.Application
$powerPoint.Visible = $true
# Open the template
$presentation = $powerPoint.Presentations.Open($templatePath, [System::Type]::Missing, [System::Type]::Missing, [System::Type]::Missing)
# Change the default font in the master slides
foreach ($slide in $presentation.Designs) {
foreach ($slideMaster in $slide.SlideMaster.CustomLayouts) {
foreach ($shape in $slideMaster.Shapes) {
if ($shape.TextFrame.HasText) {
$shape.TextFrame.TextRange.Font.Name = "Verdana"
}
}
}
}
# Save the changes
$presentation.SaveAs($templatePath)
# Close the presentation and PowerPoint
$presentation.Close()
$powerPoint.Quit()
# Release COM objects
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($slideMaster) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($presentation) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($powerPoint) | Out-Null
Write-Output "Default font in PowerPoint template has been changed to Verdana."
} else {
Write-Error "PowerPoint template not found at path: $templatePath"
}
Ensure the script is thoroughly tested in a controlled environment before deploying it broadly.
If you have any further questions or need additional assistance, feel free to ask.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.