# Macros for the WebTk Editor

Macros are canned sections of HTML markup that you can insert in one operation.

[Defining | Editing | Using | WebTk Home]

## Defining a New Macro

Start by invoking the Macro->Edit/Create Macro menu operation. This displays a dialog with two areas. On the left is a list of all the existing macros. There should be at least two, `example1` and `example2`. On the right is a blank area in which you will compose the macro. At the lower right is an entry for the name of the macro.

To define a macro first choose a name and enter that in the lower right entry area. Then simply insert the HTML that you want for the macro into the large text area to the right. Finally, use the Save button at the bottom of the dialog to save the macro. After saving, the macro should appear in the list of defined macros on the left. It will also appear in the main Macro menu on all WebTk Editor windows.

Hint: You can select formatted text from a web page and paste it into the macro definition window. Use the Edit menu to paste, or click with the middle mouse button. The raw HTML markup will be displayed. You can then hand edit the markup.

### Macros that apply to a selection.

A macro can put balanced open and close markup at either end of a selected range of text. If the macro definition contains the keyword SELECTION, then that gets replaced with the selected area of your document before the whole macro is inserted into the page. The `example1` macro uses this format.

## Editting an Existing Macro

Start by invoking the Macro->Edit/Create Macro menu operation. This displays a dialog with two areas. On the left is a list of all the existing macros. There should be at least two, `example1` and `example2`. On the right is a blank area in which you will compose the macro.

Select the macro to edit from the list on the left, and then press the Edit button at the lower left. This will fill in the name field and display the macro in the right hand area. Edit and save the macro as described above.

The Load button is used to insert another macro into the editing area. Select a macro in the listbox and then hit Load. The selected macro gets inserted into the editting area.

## Using a Macro

Select the macro from the Macro menu. The macro may have to be applied to a selection. It will tell you this if you try to use the macro with nothing selected.