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

Working with Multiple Conditions

When you apply conditional formatting, you are not limited to using a single condition. Indeed, you can set up multiple ...

Discover More

Setting Your Default Document Directory

Word allows you to specify where it should start looking for your documents. This setting can come in handy if you store ...

Discover More

Marking Multiple Documents

After using Word for a while, it is easy to accumulate quite a few documents. At some point you may want to make a change ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Starting in Safe Mode

By using a command-line switch, Excel can be started in safe mode. This means that the program is loaded with bare-bones ...

Discover More

Selecting an Entire Worksheet

While editing, you may need to select everything in a worksheet. Excel provides three easy ways you can accomplish this.

Discover More

Workaround for Multiple Rows of Worksheet Tabs

If you've got a lot of worksheets in your workbook, you may want to display their tabs in to rows at the bottom of 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 3 + 8?

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.