• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Visio / Displaying Document Fonts

Published on October 27, 2007 by David Parker

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.

image

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 & “”””
Next
End Sub

Related

Filed Under: VBA, Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. [email protected] says

    February 18, 2015 at 11:40 pm

    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.

    Reply
    • davidjpp says

      March 18, 2015 at 11:34 am

      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.

      Reply

Trackbacks

  1. More about Visio document fonts | bVisual - for people interested in Microsoft Visio says:
    July 15, 2016 at 3:20 pm

    […] 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 […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Update to LayerManager add-in for non-English users
  • Pushing Data Visualizer in Visio beyond its limits
  • Pushing Data Visualizer in Visio to the limits!
  • Teams Tuesday Podcast Recording about Visio
  • Linking Data to Visio Shapes in Code

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Themes Validation VBA Video Visio Visio 2007 Visio 2013 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • LinkedIn
  • Twitter

Search this website

Recent posts

  • Update to LayerManager add-in for non-English users
  • Pushing Data Visualizer in Visio beyond its limits
  • Pushing Data Visualizer in Visio to the limits!
  • Teams Tuesday Podcast Recording about Visio
  • Linking Data to Visio Shapes in Code

Copyright © 2023 · Executive Pro on Genesis Framework · WordPress · Log in