Consulting

Results 1 to 5 of 5

Thread: Active.Presentation.Fonts.count from 0

  1. #1
    VBAX Regular
    Joined
    May 2017
    Posts
    18
    Location

    Active.Presentation.Fonts.count from 0

    Hello

    Here is a code I wrote for checking if font is embedded. In my presentation I have 4 fonts.

    Sub ListDocumentProperties()
    
      Dim i As Integer
      
      For i = 1 To ActivePresentation.Fonts.count - 1
      
        If ActivePresentation.Fonts(i).Name = "Arial" Then
            MsgBox "Font is embedded"
        Else
            MsgBox "Font is not embedded"
        End If
        
        Next i
        
    End Sub
    Problem is that this code checks fonts 1-3 and no 0 position. How to use Fonts.count to start from 0. Something similar to array and .Length. When I change i = 0 i get Run-time error '424' Object required. I read it has something to do with VB4.

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Fonts(0) does not exist so it's not obvious what you mean.

    Testing for Arial is not a good test that the font is embedded either.

    I would forget the code you have and explain what you are trying to achieve.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    May 2017
    Posts
    18
    Location
    Hello John,

    thank you for your suggestions.

    Yes 'embedded' was misleading. I wanted to check if the specific font is used in presentation. However I don't want to check every text box font type on every slide. I wanted to check Fonts Used in current presentation properties through Document Panel and Advanced Properties. In Contents tab there is a list of Fonts Used.

    Currently I have 6 fonts on the list. Code is returning only 3.

    Am I correct that ActivePresentation.Fonts returns a fonts collection that represents all fonts used in the specified presentation?

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    The code would return only used fonts while the Doc props list also includes heading and body font which may or may not be used. To find if Arial is used try:
    Sub findFont()
    Dim objF As Font
    Dim b_found As Boolean
    For Each objF In ActivePresentation.Fonts
    If objF.Name = "Arial" Then b_found = True
    Next
    If b_found Then
    MsgBox "Arial was found."
    Else
    MsgBox "Arial not found."
    End If
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    May 2017
    Posts
    18
    Location
    Thank you John! I didn't know Doc porps includes also fonts which could be potentially used. It explains a lot.

Posting Permissions

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