Skip entry in For...Next or create a specified starting point

D

Dawn Bjork Buzbee

I have a macro (code below) that generates a sample of the fonts on a
specific computer. On one system, it found fonts (duplicates) with a name
that started with @ such as @Arial. This apparently sent a code to the
printer so it stopped printing from that point in the document. Once I
manually deleted those initial entries, the print job was fine.

Is there an easy way to either skip all entries with a prefix of @ or to
create a starting point in the list of fonts such as Aa?

Thank you in advance.

**START OF CODE

Dim iCharNumber As Integer, iPointSize As Integer, iNumberOfFonts As Integer
Dim vFontName As Variant, i As Integer
Dim sSortedFontNames() As String
ReDim sSortedFontNames(FontNames.Count)
On Error GoTo UserClickedCancel

' Prompt for point size of samples
iPointSize = InputBox("Print fonts at which point size (such as 12 or 14)?",
"Print Font List")
MsgBox "The creation of the print fonts list may take a few minutes-a prompt
will appear when the list is completed", vbInformation, "Please Wait"
On Error GoTo 0
i = 0
For Each vFontName In FontNames
i = i + 1
sSortedFontNames(i) = vFontName
Next vFontName
WordBasic.SortArray sSortedFontNames()

Selection.GoTo What:=wdGoToBookmark, Name:="start"

' Build list
For i = 1 To FontNames.Count
Selection.ParagraphFormat.KeepWithNext = True
Selection.Font.Size = 11
Selection.Font.Name = "Times New Roman"
Selection.TypeText sSortedFontNames(i) & " at " & iPointSize & " points:"
Selection.TypeParagraph
Selection.Font.Size = iPointSize
Selection.Font.Name = sSortedFontNames(i)
Selection.TypeText Text:="The quick brown fox jumps over the lazy dog"
Selection.TypeParagraph
For iCharNumber = 33 To 122
Selection.TypeText Chr(iCharNumber) & " "
Next iCharNumber
Selection.ParagraphFormat.KeepWithNext = False
Selection.TypeParagraph
Selection.TypeParagraph
Next i

UserClickedCancel:

**END OF CODE

Thank you for your help,
Dawn
 
G

Greg Maxey

Dawn

You could add a condtion:

If Not Mid(vFontName, 1) = "@" Then
sSortedFontNames(i) = vFontName
End If
 
J

Jay Freedman

Insert this line immediately after the line For i = 1 To FontNames.Count :

If Left(sSortedFontNames(i), 1) <> "@" Then

and insert this line immediately before the line Next i :

End If

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Greg Maxey

Dawn you could use a condition:


If Not Mid(vFontName, 1) = "@" Then
sSortedFontNames(i) = vFontName
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top