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

Copying Worksheets in a Macro

Copying worksheets (one or many) is easy to do manually. What is not well known is that it is even easy to make the ...

Discover More

Stopping Styles from Changing with Multiple Users

Using styles in your documents can be very helpful when it comes to consistency and ease of formatting. When others open ...

Discover More

Controlling the Italic Text Attribute

If you are formatting your document by using a macro, you may need to make some of your text italics. You do that by ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

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

Deleting Names

Excel allows you to associate names with cells or ranges of cells. If you ever want to delete those names, you'll need ...

Discover More

Task Pane Doesn't Appear Properly

Excel 2002 and 2003 include a Task pane that provides quick access to common tasks. The Task pane is normally visible ...

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 four minus 2?

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.