Results 1 to 5 of 5

Thread: changing font of text in all slides using PowerPoint VBA, macros

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2019
    Posts
    31

    changing font of text in all slides using PowerPoint VBA, macros

    Hello all,

    I am trying to set font properties to every text in presentation at same time. I tried doing this with help of following code I found on web. But I am not able to change font present in slides textboxes, charts, tables. Please help! Here the values are taken from this : https://docs.microsoft.com/en-us/off...laceholdertype

    with this code, I can influence title and subtitle but remaining body/content part of slides are not affecting. Any help is like ray of light!!Sorce : from internet ( not sure what website it is)

    Sub SetFonts()
    Dim osld As Slide, oshp As Shape
    For Each osld In ActivePresentation.Slides
    For Each oshp In osld.Shapes
    If oshp.Type = msoPlaceholder Then
    'Title text change values as required
    If oshp.PlaceholderFormat.Type = 1 Or oshp.PlaceholderFormat.Type = 4 Then
    If oshp.HasTextFrame Then
    If oshp.TextFrame.HasText Then
    With oshp.TextFrame.TextRange.Font
    .Name = "Calibr"
    .Size = 36


    End With
    End If
    End If
    End If

    If oshp.PlaceholderFormat.Type = 2 Or oshp.PlaceholderFormat.Type = 12 Then
    If oshp.HasTextFrame Then
    If oshp.TextFrame.HasText Then
    'This changes the font type and size.change values as required
    With oshp.TextFrame.TextRange.Font
    .Name = "Calibri"
    .Size = 24

    End With
    End If
    End If
    End If
    End If
    Next oshp
    Next osld
    End Sub

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,398

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2019
    Posts
    31

    Re: changing font of text in all slides using PowerPoint VBA, macros

    Hello,

    Thank you for the information. I am trying to achieve something that is similar to the code in stack overflow( above mentioned). But with a twist of setting different font sizes to texts. Like, I wish to set 24 font size to title text, 20 for subtitle text, 14 for text present in body, like content with paragraphs and all. Any thoughts on this is so helpful. My thought is to check for type using IF condition and apply respective changes.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2019
    Posts
    31

    Re: changing font of text in all slides using PowerPoint VBA, macros

    My thought is to check for type using IF condition and apply respective changes, without using 'selection'.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: changing font of text in all slides using PowerPoint VBA, macros

    without using 'selection'.
    i would think that would be much better
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width