Open all PowerPoints in a folder and update font and text

TaskMaster

Board Regular
Joined
Oct 15, 2020
Messages
75
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

We have been instructed to update all of our documents to standardise the format, of which I have about 100 PowerPoints which I would have to change the font and text colour and wondering if there is a way to automate this via some vba, my thinking would be to select the folder location and then pick up all the pptx in that location. Is anyone able to help with this?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If anyone else needs it found the following solution.

VBA Code:
Sub UpdatePowerPointPresentations()
    Dim pptApp As Object
    Dim pptPres As Object
    Dim pptSlide As Object
    Dim pptShape As Object
    Dim pptTextRange As Object
    Dim pptFolder As String
    Dim pptFile As String
    Dim NewFileName As String
    Dim fd As FileDialog
    Dim FontName As String
    Dim FontColor As Long
    
    ' Set the font name and color you want to use
    FontName = "Arial"
    FontColor = RGB(255, 0, 0) ' Red color
    
    ' Create FileDialog to select folder
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .Title = "Select Folder Containing PowerPoint Files"
        If .Show = -1 Then
            pptFolder = .SelectedItems(1) & "\"
        Else
            Exit Sub
        End If
    End With
    
    ' Create PowerPoint application object
    On Error Resume Next
    Set pptApp = CreateObject("PowerPoint.Application")
    On Error GoTo 0
    If pptApp Is Nothing Then
        MsgBox "PowerPoint is not installed or not available."
        Exit Sub
    End If
    
    pptApp.Visible = True
    
    ' Loop through all PowerPoint files in the folder
    pptFile = Dir(pptFolder & "*.ppt*")
    Do While pptFile <> ""
        Set pptPres = pptApp.Presentations.Open(pptFolder & pptFile, WithWindow:=msoFalse)
        
        ' Loop through each slide in the presentation
        For Each pptSlide In pptPres.Slides
            ' Loop through each shape in the slide
            For Each pptShape In pptSlide.Shapes
                ' Check if the shape has text
                If pptShape.HasTextFrame Then
                    If pptShape.TextFrame.HasText Then
                        Set pptTextRange = pptShape.TextFrame.TextRange
                        pptTextRange.Font.Name = FontName
                        pptTextRange.Font.Color.RGB = FontColor
                    End If
                End If
            Next pptShape
        Next pptSlide
        
        ' Save the presentation with "updated" appended to the file name
        NewFileName = pptFolder & Left(pptFile, InStrRev(pptFile, ".") - 1) & " updated" & Mid(pptFile, InStrRev(pptFile, "."))
        pptPres.SaveAs NewFileName
        pptPres.Close
        
        ' Get the next PowerPoint file
        pptFile = Dir
    Loop
    
    pptApp.Quit
    Set pptApp = Nothing
    
    MsgBox "All PowerPoint presentations have been updated and saved."
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top