Consulting

Results 1 to 5 of 5

Thread: Unable to Replace Certain Fonts

  1. #1

    Question Unable to Replace Certain Fonts

    I have a powerpoint presentation that I inherited that is causing some drama because of a few fonts, namely Times (not to be confused with Times New Roman) and Noto Sans Symbols that are showing up as "unsupported" for some of our users. These fonts need to be replaced throughout the presentation, wherever they may exist, but Replace > Replace Fonts is not working for these. There are a few things I have tried:

    Sub ReplaceFontToArial()
      Dim objSingleWord As Range
      Dim objDoc As Presentation
    
    
      Set objDoc = ActivePresentation
    
    
      With objDoc
        For Each objSingleWord In .Words
          If objSingleWord.Font.Name = "Times" Then 
            objSingleWord.Font.Name = "Arial"
          End If
        Next
      End With
    End Sub
    But, it errors out highlighting `ObjSingleWord As Range` and stating, `Compile error: User-defined type not defined`.

    Then, upon a suggestion from the Microsoft VBA reference docs, I tried:

    Sub ReplaceFontToArial()
      Application.ActivePresentation.Fonts.Replace Original:="Times", Replacement:="Arial"
    End Sub
    But this errors out with a `Run-time error '424': Object required`.

    I'm completely out of thoughts to fix this problem. Any help on how I can change out these crazy fonts and what I'm doing wrong would be amazing!!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Using PP 365 and the online Help:


    You can also use the Replace Font option to change a font throughout your presentation. Here's how:

    1. On the Home tab, in the Editing group, select Replace and then select Replace Fonts.
    2. In the Replace Font dialog box, in the Replace field, select the font that you want to replace.
    3. In the With field, select the font that you want to use, select Replace, and then select Close.
    Fonts.jpg

    It might be possible to automate that, but once it's converted, why bother?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    As I stated, Replace > Replace Fonts is not working for these particular fonts, which is sometimes a known issue for PPT. Therefore, I am seeking a programmatic way of ridding myself of this problem. What I have tried so far is not working, therefore I am seeking assistance, The only other answer I've been offered is that I might want to ZIP the presentation, unzip it, use an OOXML view to find the fonts, and using Notepad, replace the offending fonts with what they should be, zip it back up, and change the extension back to pptx. My concern with this is that OOXML fiddling has known to cause errors. Plus, if there is a programmatic way of doing this, wouldn't that be the way to go?

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Sorry, misunderstood

    Can you post a single slide presentation with the font problem
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Your vba code is not correct so first try

    Sub ReplaceFontToArial()
      Dim objDoc As Presentation
      Dim oshp As Shape
      Dim osld As Slide
      Dim L As Long
      Set objDoc = ActivePresentation
    For Each osld In objDoc.Slides
    For Each oshp In osld.Shapes
    If oshp.HasTextFrame Then
    If oshp.TextFrame.HasText Then
    With oshp.TextFrame.TextRange
    For L = 1 To .Words.Count
    Debug.Print .Words(L).Font.Name
    If .Words(L).Font.Name = "Times" Then .Words(L).Font.Name = "Arial"
    Next L
    End With
    End If
    End If
    Next oshp
    Next osld
    End Sub
    Some fonts cannot be replaced so you may have to go down the XML route.

    Try this:

    Work on a cOPY!

    Save as a PowerPoint XML file

    Open in Notepad

    Replace Times with Arial (or whatever)

    Save
    Open in PowerPoint and resave as a PPTX.
    Last edited by John Wilson; 08-25-2019 at 03:07 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

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
  •