vbapowerpoint-2013

How to change the font of a selection in powerpoint 2013 with VBA


I would like to to change for the text selection in powerpoint 2013 the font to be bold and "Couirier New". I tried with this VBA script to change the font:

Sub chengeFont()
    With ActiveDocument.Selection
        With .Font
            .Name = "Courier New"
        End With
    End With
End Sub

but it is not working. Any suggestions?


Solution

  • This will change the font and make it bold when you run it

    With ActiveWindow.Selection.TextRange.Font
        .Name = "Courier New"
        .Bold = msoTrue
    End With
    

    Since you are running it from a selection the document will should always be the active one, other wise you will need to change the ActiveWindow