Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-10-2021, 07:17 PM
Guessed's Avatar
Guessed Guessed is offline Need Help Modifying Code to print all fonts Windows 10 Need Help Modifying Code to print all fonts Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I prefer to load this type of information to a table so it can be sorted and formatted more easily. Try this variation on the code.
Code:
Sub InsertAllFontSamples()
  'Inserts samples of all installed fonts into the current file
  Dim strFont As Variant, sText As String, oTbl As Table, aRng As Range, oRow As Row
  sText = "The quick brown fox jumped over the lazy dog. 12345 67890"
  Application.ScreenUpdating = False
    Set aRng = Selection.Range
    Set oTbl = ActiveDocument.Tables.Add(Range:=aRng, numrows:=1, numcolumns:=2)
    oTbl.cell(1, 1).Range.Text = "Font"
    oTbl.cell(1, 2).Range.Text = "Sample"
    oTbl.Range.Style = wdStyleNormal
    oTbl.Columns(1).PreferredWidthType = wdPreferredWidthPercent
    oTbl.Columns(1).PreferredWidth = 30
    oTbl.Columns(2).PreferredWidth = 70
    For Each strFont In Application.FontNames
      Set oRow = oTbl.Rows.Add
      oRow.Cells(1).Range.Text = strFont
      oRow.Cells(2).Range.Text = sText
      oRow.Cells(2).Range.Font.Name = strFont
    Next strFont
    oTbl.ApplyStyleHeadingRows = True
    oTbl.SortAscending
  Application.ScreenUpdating = True
  MsgBox "Macro finished!"
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
list of fonts, spacing issues, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot print specific fonts Head Word 4 06-23-2018 06:03 PM
Need Help Modifying Code to print all fonts Need help with modifying a replacing font VBA code- similar task but subtle change kissingfrogs2003 Word VBA 3 08-30-2016 11:42 AM
Code to Print page 2 only Bursal Word VBA 1 05-05-2016 09:58 PM
How to print a line of text with all available fonts in the same document electrocad Word VBA 1 10-17-2015 04:53 AM
vba Code to Print Spreadsheet to PDF OTPM Excel Programming 3 05-25-2011 08:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft