PDA

View Full Version : Active.Presentation.Fonts.count from 0



YorickG
06-26-2018, 02:32 AM
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.

John Wilson
06-26-2018, 02:53 AM
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.

YorickG
06-26-2018, 03:15 AM
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?

John Wilson
06-26-2018, 04:10 AM
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

YorickG
06-26-2018, 04:20 AM
Thank you John! I didn't know Doc porps includes also fonts which could be potentially used. It explains a lot.