Example: Assigning Macros to Shortcut Keys

From Apache OpenOffice Wiki
< Documentation‎ | AOO4 User Guides/Writer Guide‎ | Customizing Writer‎ | Assigning Shortcut Keys
Revision as of 10:10, 12 October 2025 by DiGro (talk | contribs) (Created page with "{{DISPLAYTITLE:Example: Assigning Macros to Shortcut Keys}} {{Documentation/WG4CustWriterTOC |ShowPrevNext=block |PrevPage=Documentation/AOO4_User_Guides/Writer Guide/Customiz...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Example: Assigning Macros to Shortcut Keys

A common use for assigning macros to shortcut keys is to enable quick and easy insertion of special characters. This example shows how to set up keyboard shortcuts for inserting en dashes and em dashes. The en dash is approximately the length of the letter N, and the em dash the length of the letter M. The shorter en dash (–) is used to mark ranges and with the meaning “to” in phrases like “Dover–Calais crossing.” The longer em dash (—) is used to separate extra information or mark a break in a sentence. First, you need to record a macro for inserting each type of dash. Then, you need to assign those macros to shortcut key combinations.

1) Choose Tools → Macros → Record Macro to start recording a macro.

A small window is displayed, so you know that OpenOffice is recording.

AOO41WG16 007a RecordMacro.png
  1. Choose ((menu|Insert|Special Characters}} to open the Special Characters dialog box. Scroll down until you find the en dash (U+2013) and em dash (U+2014) characters. Select one of them and click  OK .
AOO41WG16 008.png
Figure 8: Find and choose the en dash.
  1. Click the  Stop Recording  button to stop recording, save the macro, and display the OpenOffice Basic Macros dialog box (see Figure 9). Type a descriptive name for the new macro in the Macro name box on the upper left.
AOO41WG16 009.png
Figure 9: Naming the new macro and storing it.
  1. 4) Be sure to open the library container named My Macros. Find the library named Standard under My Macros. Select Module1 and click  Save . The libraries listed under My Macros on your system will likely be different from those shown in the figure, but Standard will always be present.
  2. Repeat steps 1–4 to create other macros, for example to insert an em dash.
  3. Choose Tools → Customize → Keyboard tab (Figure 10). In the Shortcut keys list, pick an unused combination (for example,  Ctrl  +  ⇧ Shift  +  N  for an en dash). In the Category list, scroll down to OpenOffice Macros, click the + sign (or small triangle, depending on your operating system), then click the + (or triangle) next to user and then next to the Standard library and select Module1. In the Function list, pick endash and click the  Modify  button on the upper right. The selected key combination now appears in the Keys list on the lower right, and endash appears next to  Ctrl  +  ⇧ Shift  +  N  in the Shortcut keys list.
  4. Repeat for the em dash macro, then click  OK .
Tip.png For inserting en and em dashes, and other special characters, you may find extensions such as Compose Special Characters useful. See “Adding Functionality with Extensions”.


AOO41WG16 010.png
Figure 10: Defining keyboard shortcuts for running macros.
Personal tools