Displaying Document Fonts

There have been some posts recently about fonts may not displaying correctly in Visio, the Viewer, or in exports to PDF or XPS.  So, I thought it would be good to be have a bit of code that enables you to see all of the different fonts on a Visio page.  You can then use it to select a font, or to check how they are seen in different formats.


The following code will divide the active Visio page into three columns, creating a separate shape for each font name in order.  The font index and name are displayed in the particular font, but the ScreenTip of each shape displays the information, just in case you can’t read it in the shape!

Public Sub DisplayFonts()
Dim fnt As Visio.Font
Dim shp As Visio.Shape
Dim cols As Integer
Dim col As Integer
Dim maxRows As Integer
Dim row As Integer

Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim width As Double
Dim height As Double

cols = 3
col = 0
maxRows = CInt(1 + (Visio.ActiveDocument.Fonts.Count / cols))
width = ((Visio.ActivePage.PageSheet.Cells(“PageWidth”).ResultIU – _
Visio.ActivePage.PageSheet.Cells(“PageLeftMargin”).ResultIU – _
Visio.ActivePage.PageSheet.Cells(“PageRightMargin”).ResultIU) / cols)
height = ((Visio.ActivePage.PageSheet.Cells(“PageHeight”).ResultIU – _
Visio.ActivePage.PageSheet.Cells(“PageTopMargin”).ResultIU – _
Visio.ActivePage.PageSheet.Cells(“PageBottomMargin”).ResultIU) / maxRows)

For Each fnt In Visio.ActiveDocument.Fonts

If row Mod maxRows = 0 Then
col = col + 1
End If

row = row + 1
x1 = Visio.ActivePage.PageSheet.Cells(“PageLeftMargin”).ResultIU + (col – 1) * (width)
y1 = Visio.ActivePage.PageSheet.Cells(“PageHeight”).ResultIU – _
Visio.ActivePage.PageSheet.Cells(“PageTopMargin”).ResultIU – _
((row – ((col – 1) * maxRows) – 1) * height)
x2 = x1 + (Visio.ActivePage.PageSheet.Cells(“PageWidth”).ResultIU / cols)
y2 = y1 + height
Set shp = Visio.ActivePage.DrawRectangle(x1, y1, x2, y2)
shp.Text = fnt.id & vbTab & fnt.Name
shp.Cells(“Para.HorzAlign”).Formula = “=0”
shp.Cells(“Geometry1.NoFill”).Formula = “=1”
shp.Cells(“Geometry1.NoLine”).Formula = “=1”
shp.Cells(“Char.Size”).Formula = “=8 pt”
shp.Cells(“Char.Font”).Formula = “=” & CStr(fnt.id)
shp.Cells(“Comment”).Formula = “=””” & fnt.id & vbCrLf & fnt.Name & “”””
End Sub

Posted in Visio. 3 Comments »

3 Responses to “Displaying Document Fonts”

  1. t@yahoo.co.uk Says:

    I was unable to get this to work, the width and height sections were all in red, real shame as this is exactly what I was looking form.

    • davidjpp Says:

      Ah, I see what you mean. When you copy and paste into the VBA editor, the “-” characters must have a different ASCII code. I was able to fix this by just replacing the “-” characters with the one on my keyboard … then the red disappeared and the code compiled and ran.

  2. More about Visio document fonts | bVisual - for people interested in Microsoft Visio Says:

    […] in 2007, I wrote an article about Visio Document fonts ( see Displaying Document Fonts ), but I did not notice the importance of the screenshot that shows the fonts with the IDs from 10 […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


O365 and SharePoint

Simplify Tasks

Want to learn the simple way?

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

John Goldsmith's visLog

be smart, be clear, be visual ...

Mo's blog

Personal views on Dynamics 365 for Operations and Technical Architecture.

Chris Webb's BI Blog

Microsoft Power BI, Analysis Services, MDX, DAX, M, Power Pivot and Power Query


Azure Solutions for Office 365, and more...

Rob Fahrni



Life with Visio and other Microsoft Toys!

Nilsandrey's Weblog

Just another WordPress.com weblog

Things that Should be Easy

Every so often (too often in the IT industry) I encounter things that should have been very easy to do but turned out to be far too complicated. My favorite topics include SharePoint, .Net development, and software architecture, especially distributed systems.

Visio Guy

Smart graphics for visual people

%d bloggers like this: