Lene Fredborg, DocTools, har hvert år siden 2008 modtaget den prestigefyldte pris som Microsoft Most Valuable Professional (MVP) i Word – link til information om MVP Award'en DocTools - dokumentautomatisering - add-ins, makroer og skabeloner til Microsoft Word (logo) Dokumentautomatisering
Add-ins & Makroer
Skabeloner
Til Microsoft Word
Dokumentautomatisering, skabeloner (templates), add-ins og makroer til Microsoft Word (grafik)



Bogmærk denne side | Tip en ven om DocTools


Søg thedoctools.com:

Custom Search



Macro ready for use...

Macro – Add Screen Tips to Text in Microsoft 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.

Terms of use

You are welcome to use the macros and Word tips provided on this website. The contents is copyright. You may not reproduce any of contents (with or without modification or credits) elsewhere on the web, or on CD. Please link to the contents on this website instead.

Please note that all free Word tips, macros, add-ins and demos are provided "as is" and without obligation. See also detailed Terms of use.


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 256 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:

How screen tips will appear in the document

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:

Option that determines how to follow a hyperlink

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.

The option must be turned on in order to display screen tips

In order to make the selection remain unchanged if a user Ctlr+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:

The field code of the screen tip hyperlink illustrated above

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.



Related information

See general information about VBA macros and code snippets, incl. information about how to install macros.



Top of page

Back to Macros...




Copyright © 2006-2017 Lene Fredborg – DocTools ApS – alle rettigheder forbeholdt | Microsoft Word skabeloner (templates) – add-ins – VBA makroer | Spar tid og arbejd mere effektivt i Microsoft Word
Privat politik | Betingelser for brug | Om cookies | Bogmærk denne side | Tip en ven | Links | Kontakt