This is the wrong way, I think. We are looking for the inclusion of a font, not the location of this font. This is an existential rather than a positional problem.
Significantly, much, much faster, repeat the fonts. The only trick is that the Word is sometimes fussy about spaces, etc. It works well for me
Sub FindAllFonts() Dim lWhichFont As Long, sTempName As String, sBuffer As String For lWhichFont = 1 To FontNames.Count sTempName = FontNames(lWhichFont) If FindThisFont(sTempName) Then sBuffer = sBuffer & "Found " & sTempName & vbCrLf Else If FindThisFont(Replace(sTempName, " ", "")) Then sBuffer = sBuffer & "Found " & sTempName & " *" & vbCrLf End If End If Next Documents.Add Selection.TypeText Text:=sBuffer End Sub Function FindThisFont(sName As String) As Boolean Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting With Selection.Find .Font.Name = sName .Forward = True .Format = True .Execute If .Found() Then FindThisFont = True Else FindThisFont = False End If End With End Function
It works very fast (the only slow component is font iteration)
(Of course, he will not find fonts not on your system, but if you are trying to prepare for transport what you wrote, and some kind of assistant program installed Helvetica or MS Minchin, you can find it)
OK, people told me that not everyone wants this, people want to find fonts that are not on their machines. But the other way is still too slow and requires looking for a lot of things not there. So here is an alternative that is saved as rtf and processes the rtf header.
Sub FIndAllFonts2() Dim sOldName As String, sOldPath As String, sBuffer As String, sBuffer2 As String, sOut As String, sBit Dim lCounter As Long, lPos As Long, lPos2 As Long, lStopAt As Long Dim objPic As InlineShape, objShp As Shape ' rememer old name for reloading sOldName = ActiveDocument.Path 'delete image to make file out small For Each objPic In ActiveDocument.InlineShapes: objPic.Delete: Next For Each objShp In ActiveDocument.Shapes: objShp.Delete: Next ActiveDocument.SaveAs "tempout.rtf", wdFormatRTF sTempFile = ActiveDocument.Path ActiveDocument.Close lPos2 = 1 ' we only want the header, but we don't know how long the file is 'I am using a Mac, so filesystemobject not available ' if you end up having a huge header, make 2500 bigger lStopAt = 2500 Open sTempFile For Input As
It goes through my 350 page project in 20 seconds on a MacBook Pro. Therefore, it is fast enough to be useful.