Add Screen Tips to Text in Word

Many users want to be able to make small screen tips in Word that work like the screen tips known from Websites, i.e. small boxes with information that appear when you hover the mouse over a text like here. For example, such screen tips may be used to show definitions of terms. Word has no functionality specifically for that but you can make use of the hyperlink functionality and obtain something similar.

You can create such "screen tips hyperlinks" manually. However, this includes a number of steps: You must select text, add a bookmark with an appropriate name, create a hyperlink and enter the screen tip text, and format the text.

Here you will find a set of macros that automate the process. One macro lets you add screen tips hyperlinks in a structured way and another one lets you easily remove a screen tip hyperlink again if you wish.

Instead of installing the macro solution available on this page you may be interested in the ready-to-use add-in DocTools ScreenTipManager. You will find an introduction and a link to that add-in below.

Word add-in ready for use

DocTools ScreenTipManager - advanced add-in for Word

Free Trial icon
Word Add-In from DocTools

DocTools ScreenTipManager makes it fast and easy to create and edit screen tips in Word with up to 2040 characters.

Screen tips you create using the free macro solution on this page are limited to 255 characters. The add-in also includes many other features.

The add-in works with Microsoft Word 2010 and newer versions on PC/Windows.

You can access the functionality of the add-in from a custom tab in the Ribbon.

How to get the DocTools ScreenTipManager add-in

This advanced add-in is not free but the return on investment is almost immediate. It will make all your future work with screen tips fast and easy.

Click the button below to learn more about DocTools ScreenTipManager or to buy the add-in.

You can try DocTools ScreenTipManager risk-free for 7 days.

Macro solution

Read below if you want to use the macro instead of the add-in.

How the screen tips macros work

The macro module you can download via the link below contains three macros:

  • AddScreenTipToText
  • GetBookmarName (used by the macro above)
  • RemoveScreenTipFromText

For easy access, you can assign keyboard shortcuts to the macros. Alternatively, you can assign the macros to a toolbar (Word 2003 and earlier versions) or the Quick Access Toolbar (QAT) (Word 2007 and later versions).

To add a screen tip hyperlink, select the relevant text, run the macro AddScreenTipToText. In the dialog box that opens, enter the text you want to appear in the screen tip. Click OK.

The text you entered will now appear in a screen tip when a user hovers the mouse over the text. Shading will be applied to the hyperlinked text in order to make it easy for the user to identify text with screen tips. The normal Hyperlink style will automatically be removed from the hyperlink so that the user can distinguish screen tip hyperlinks from ordinary hyperlinks. You can change the shading color in the macro if you wish.

If you wish to break your screen tip text into multiple lines, follow the instructions in the dialog box. In the example illustrated below, a screen tip with two lines of text is created.

To remove a screen tip, select the screen tip hyperlink or just click in it. Then run the macro RemoveScreenTipFromText.

Note that the screen tip text cannot exceed 255 characters.

For further details about how the macros work, please refer to the comments in the macros.

The illustration below shows the dialog box in which you specify the screen tip text. A sample text has been inserted:

The dialog box in which you must enter the desired screen tip text

The illustration below shows how screen tips hyperlinks will appear in the document. The displayed screen tip contains the text entered in the dialog box illustrated above:

Example of screen tip

Additional hints about how the screen tips work

You do not need to read the following in order to use the macros. However, it may help you understand how it works.

You only need the macros in order to add/remove screen tips hyperlinks. No macros need to be available to the end user of the document. This means that you can store the macros e.g. in your Normal.dot/Normla.dotm or in a global template placed in your Word Startup folder.

Since the screen tips are actually made as hyperlinks, you will find the standard hyperlink text Ctrl + click to follow link or Click to follow link at the bottom of the screen tips. That text cannot be removed. Whether Ctrl + click or only Ctrl is shown depends on whether or not the option Use Ctrl + click to follow hyperlink is turned on – here shown as it appears in Word 2003; in Word 2007 and 2010 you will find the option in the Word Options dialog, below the Advanced category:

Where to find Word option for clicking hyperlinks

The Word option for displaying screen tips must be turned on. In Word 2003, you will find the option here:
Tools > Options > View tab > Show group > Screen Tips.

In Word 2007 you will find the option here:
Office button > Word Options > Display category > Show document tooltips on hover.

In Word 2010, Word 2013 and Word 2016, you will find the option here:
File > Options > Display category > Show document tooltips on hover.

Note the screen tips are automatically turned on by the AddScreenTipToText macro. If the screen tips do not appear on a user's PC, ask the user to turn on the option on his/her PC.

Word option for showing screen tips

In order to make the selection remain unchanged if a user Ctrl+clicks or clicks the hyperlink, a bookmark is added around the hyperlink itself and the hyperlink is defined to go to that bookmark, i.e. the cursor does not jump to another place.

Hyperlinks are fields. A field contains field code, i.e. instructions to Word about what to do. You can display the field codes by pressing Alt+F9. If you display field codes, you will see that the screen tips hyperlinks look as illustrated below. Note that formatting marks are shown so that you can se both the paragraph mark in the two-line screen tip and the spaces in the field code:

Hyperlink field code

The field consists of these parts:

  • HYPERLINK is the field type
  • \l tells Word to go to the bookmark named "_ScreenTip_4"
  • \o tells Word to display the text that follows as screen tip text

Note that all the bookmarks created by the AddScreenTipToText macro are named "_SrceenTip_X" where X is a number. Bookmarks that start with an underscore are treated as hidden. If you open the Bookmark dialog box, you need to turn on Hidden bookmarks to see the bookmarks in the list. You cannot manually create hidden bookmarks. They can only be added programmatically. It you do not want the bookmarks to be hidden, you must change the macro code.

If you copy a screen tip hyperlink to another place in the same document, the copy points to the bookmark in the original screen tip since the bookmark name in the field code has not been changed. Thus, if a user clicks such copied screen tip hyperlink, the cursor will now jump to the original screen tip. The easiest way to correct this may be to remove the copied screen tip hyperlink using the RemoveScreenTipFromText macro and then create a new one using the AddScreenTipToText macro. The AddScreenTipToText macro always creates a uniquely named bookmark in the correct place.

Screen tips hyperlinks can only be seen in the Word document. For example, they will not appear if you create a PDF file.

The macros

Below, you will find the macro code. If you need help on installing macros, see How to install a macro.

Option Explicit

'=========================
'Macros created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
'THE MACROS ARE COPYRIGHT. YOU ARE WELCOME TO USE THE MACROS BUT YOU MUST KEEP THE LINE ABOVE.
'YOU ARE NOT ALLOWED TO PUBLISH THE MACROS AS YOUR OWN, IN WHOLE OR IN PART.    
'=========================
'See the comments in the individual macros
'=========================

'Constants used by the procedures below - you may change the values
'Used when naming bookmarks:
Public Const cstrBKStart = "_ScreenTip_"

'Used for messages:
Public Msg As String
Public Title As String
Public Style As VbMsgBoxStyle
Public Response As VbMsgBoxResult

Sub AddScreenTipToText()

    'Created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
    
    'The macro converts selected text to a hyperlink that shows
    'the screen tip text you specify when a user hovers the mouse over the text.
    'In order to make it easy for the user to identify text with screen tips,
    'a shading color is applied to the text.
    'For further details, see the comments below.

    Dim oRange As Range
    Dim strBK As String
    Dim oHL As Hyperlink
    Dim strScreeenTip As String
    Dim oColor As WdColor
    Dim strScreenTip As String
    Dim strLineSeparator As String
    
    Title = "Add Screen Tip to Selection (Max. 255 Characters)"
    
    'The color specified below will be applied to the selected text
    'You can change the color if you wish
    oColor = wdColorLightTurquoise
    
    'The string specified below can be used to specify a line break
    'in the screen tip text
    'If you need the specified character to be included in the screen tip text as such,
    'change the character to something that will not be used in the screen tip texts
    strLineSeparator = "#"
    
    'Stop if no text is selected
    If Selection.Type = wdSelectionIP Then
        Msg = "Please select the text to which you want to apply a screen tip. Then select this command again."
        MsgBox Msg, vbOKOnly, Title
        Exit Sub
    End If
    
    'Stop if a hyperlink is in the selection
    If Selection.Hyperlinks.Count > 0 Then
        Msg = "The selection already contains hyperlink(s). No changes will be made."
        MsgBox Msg, vbOKOnly, Title
        Exit Sub
    End If
    
    'Let user specify screen tip text
Retry:
    Msg = "This command lets you change the selection so that a screen tip appears if a user hovers the mouse over the text." & vbCr & vbCr & _
            "The command converts the selected text to a hyperlink. In order to make the selection remain unchanged if a user " & _
            "clicks the hyperlink, a bookmark will be added around the hyperlink itself and the " & _
            "hyperlink will be defined to go to that bookmark is the user clicks it. Shading will be applied to the hyperlinked text. " & _
            "in order to make it easy for the user to identify text with screen tips." & vbCr & vbCr & _
            "Please enter the screen tip text you want to appear when the user hovers the mouse over the selected text " & _
            "(to indicate a line break, type " & strLineSeparator & "):"
        
    strScreenTip = InputBox(Msg, Title)

    If Len(strScreenTip) = 0 Then
        If StrPtr(strScreenTip) = 0 Then
            'Cancel clicked
            Exit Sub
        Else
            'OK clicked, empty field
            Msg = "You must enter the desired sceen tip text. Please retry."
            Style = vbOKOnly + vbInformation
            Response = MsgBox(Msg, Style, Title)
            GoTo Retry
        End If
    Else
        'Input accepted
        'Replace any strLineSeparator in the screen tip with vbCr
        strScreenTip = Replace(strScreenTip, strLineSeparator, vbCr)
        
        Set oRange = Selection.Range
        
        'Add bookmark around oRange
        strBK = GetBookmarkName
        oRange.Bookmarks.Add Name:=strBK
        
        'Convert selection to hyperlink
        Set oHL = oRange.Hyperlinks.Add(Anchor:=oRange, Address:="", SubAddress:=strBK)
        With oHL
            .ScreenTip = strScreenTip
            With .Range
                'Reset font to remove the hyperlink style (default: blue and underlined)
                'If your document is not formatted with proper styles,
                'you may need to change the following code
                .Font.Reset
                .Shading.BackgroundPatternColor = oColor
                'Make sure the shading stops after the range
                .Start = .End
                .Font.Reset
            End With
        End With
    End If
    
    'Make sure screen tips are shown
    Application.DisplayScreenTips = True
    
    'Clean up
    Set oRange = Nothing
    Set oHL = Nothing

End Sub

Function GetBookmarkName() As String
    
    'Created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
    
    'Function used by the AddScreenTipToText macro.
    'Creates a unique bookmark name in the format "_ScreenTip_X"
    
    Dim n As Long
    
    n = 1
    
    Do Until ActiveDocument.Bookmarks.Exists(cstrBKStart & n) = False
        n = n + 1
    Loop
    
    GetBookmarkName = cstrBKStart & n
End Function

Sub RemoveScreenTipFromText()
    'Removes hyperlink added to text using the AddScreenTipToText macro
    'The cursor must be in the hyperlink or the selection must include the hyperlink
    
    Title = "Remove Screen Tip From Selection"
    
    'Stop if not precisely 1 hyperlink is in the selection
    If Selection.Hyperlinks.Count <> 1 Then
        Msg = "You must first click in or select a single hyperlink that has been added " & _
            "via the AddScreenTipToText macro. Please retry."
        MsgBox Msg, vbOKOnly, Title
        Exit Sub
    End If
    
    With Selection.Hyperlinks(1)
        If InStr(1, .SubAddress, cstrBKStart) > 0 Then
            'Remove background color
            .Range.Shading.BackgroundPatternColor = wdColorAutomatic
            'Remove hyperlink, i.e. convert to normal text
            .Delete
        End If
    End With
    
End Sub

Related information

See About VBA Macros and Code Snippets and How to Install a Macro for misc. information that may help you in your work with macros and for information about how to install macros.