Embedding Fonts in Excel

by Allen Wyatt
(last updated August 3, 2017)

1

If you are familiar with Word and PowerPoint, you may have noticed that both programs allow you to embed fonts in documents or presentations. This is very handy, particularly if you feel that someone else receiving your document or presentation may not have your font on their system.

Unfortunately, Excel does not allow you to embed fonts in workbooks. Word has an intimate relationship with something in concrete reality: the printed page. Almost everything it does is in relationship to how something will be printed, and Word queries the printer driver many times during an editing session in order to represent information accurately onscreen. PowerPoint, as well, makes at least some reference to what can be printed or displayed onscreen.

Excel, on the other hand, is not all that interested in printing because a worksheet is really just a representation of a set of quantities and relationships--things which are fundamentally abstract. In fact, it wasn't until Excel 95 that Excel's default font was changed to Arial (a TrueType font) instead of MS Sans-Serif (a non-scalable screen font whose printing vagaries are legion).

If you really must embed fonts to make your worksheet appear properly, there is one thing you can try: Embed the Excel worksheet in a Word document in which the desired font is also embedded. You will need to make sure, of course, that the font you've chosen is embeddable (some are not). When someone else opens the document, they may see the information as you intended. Of course, they will need to use Word instead of Excel for viewing the information.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1969) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Disabling Moving Between Worksheets

If you want someone to not be able to move from one worksheet to another in a workbook, you've got your work cut out for ...

Discover More

Columns in a Text Box

Want to divide a text box into columns? Word doesn't allow you to do this, but there are ways to work around the limitation.

Discover More

Fixing Odd Sorting Behavior

When you sort data that contains both numbers and text, you may not get exactly the result that you expected. To know ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Defining a Name

One of the great features of Excel is that it allows you to use named ranges. These can make your formulas much easier to ...

Discover More

Setting the Width for Row Labels

Excel displays, by default, a row label or heading at the left side of each row on the screen. As you scroll down the ...

Discover More

Changing Excel's Starting Date

When keeping track of dates, internally, Excel uses special date serial numbers that are based upon a specific day in the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 3?

2018-08-07 10:03:38

Santiago Clausse

There's actually a very simple method to embed the font in an Excel file.

1. Create a new sheet called 'fonts'
2. In the fonts sheet Insert > Object > Create from file
Now select your ttf font file, then press OK.

This should now create an object with the name of the font you inserted and a .ttf extension.

3. Select the object, and rename it to the same name as the font, including the .ttf. For example: Linearicons-Free.ttf

4. Add the following VBA code to the 'ThisWorkbook' object in the Visual Basic editor ( Developer > Visual Basic)

' force explicit variable declaration
Option Explicit

' set default array subscripts to 1
Option Base 1

' 32bit & 64bit dec's
#If VBA7 And Win64 Then
Private Declare PtrSafe Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFilename As String) As LongPtr
Private Declare PtrSafe Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFilename As String) As LongPtr
#Else
Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFilename As String) As Long
Private Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFilename As String) As Long
#End If

' // copy the OLE objects out to the users "temp" Folder & install the Fonts as a resource upon opening the Workbook
Private Sub Workbook_Open()

' // vars
Dim objFont As OLEObject
Dim objFilename As String
Dim objShell As Object
Set objShell = CreateObject("shell.application")
Dim objFolder As Variant
Set objFolder = objShell.Namespace(Environ("Temp") & Application.PathSeparator)
Dim objFolderItem As Variant
Set objFolderItem = objFolder.Self

' // copy out the OLE objects from the "fonts" Worksheet into a temp Folder
For Each objFont In Worksheets("fonts").OLEObjects
' // get the Filename of each Font Object
' Please note: you must set this yourself when you add embed the Fonts
objFilename = objFont.Name
' // Copy the Font to the Clipboard
objFont.Copy
' // Paste the Font from the Clipboard to the "temp" Folder
If Dir(CStr(Environ("Temp") & Application.PathSeparator & objFilename), vbDirectory) = vbNullString Then
objFolderItem.InvokeVerb ("Paste")
End If
' // add each Font as a resource in Excel
AddFontResource Environ("Temp") & Application.PathSeparator & objFilename
Next objFont

' fixes Excel 2013 update fonts issue
Application.ScreenUpdating = False: ActiveSheet.Select: Application.ScreenUpdating = True

' // clean up
Set objFont = Nothing
Set objShell = Nothing

End Sub

' // remove the Font resource upon closing the Workbook
Private Sub Workbook_BeforeClose(Cancel As Boolean)

' // vars
Dim objFont As OLEObject
Dim objFilename As String

' // loop the OLE objects in the "fonts" Worksheet
For Each objFont In Worksheets("fonts").OLEObjects
' // set the Filename
objFilename = objFont.Name
' // remove the resource
RemoveFontResource Environ("Temp") & Application.PathSeparator & objFilename
Next objFont

' // clean up
Set objFont = Nothing

End Sub


And that's it! Now run the Private Sub Workbook_Open() and you should have the font embedded.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.