Example Macros
Following are several examples illustrating different types of macros.
Emphasizing Content
This macro selects the word before the cursor, adds an emphasis tag (for example, Italic from the toolbar), and moves the cursor after the </emphasis> tag.
<macro name="MakeItalic">
<desc>Macro recorded 04/01/2004.</desc>
<script type="application/x-acl"><![CDATA[
WordLeftExtend;
Italic;
ElementEnd;]]>
</script>
</macro>
Find and Replace
This macro finds the next occurrence of a phrase and replaces it with a text entity.
<macro name="SwitchToEntity">
<desc>Macro recorded 04/01/2004.</desc>
<script type="application/x-acl"><![CDATA[
#FindReplace;
find("Arbortext Editor", 0xb30);
insert_entity("&AE");]]>
</script>
</macro>
Applying Markup to Content
This macro finds the next occurrence of a phrase and surrounds it with an element.
<macro name="FixProductName">
<desc>Macro recorded 04/01/2004.</desc>
<script type="application/x-acl"><![CDATA[
#FindReplace;
find("Arbortext Editor", 0xb30);
insert_tag("productname");]]>
</script>
</macro>
Indexing
This macro performs the following actions:
1. Selects the previous two words.
2. Deletes the selected words.
3. Inserts an indexterm element with primary and secondary children.
4. Pastes the first word inside the primary element.
5. Pastes the second word inside the secondary element.
<macro name="InsertIndexterm">
<desc>Macro recorded 04/01/2004.</desc>
<script type="application/x-acl"><![CDATA[
WordLeftExtend; repeat;
EditCut;
insert_tag("indexterm");
EditPaste;
WordLeftExtend;
EditCut;
ElementEnd;
insert_tag("secondary");
EditPaste;
ElementEnd; repeat;]]>
</script>
</macro>
JavaScript
Following is an example macro written using JavaScript:
<macro name="JavaScriptMacro"
key="Alt+Ctrl+F1">
<desc>Test JavaScript macro.</desc>
<script type="application/x-javascript"><![CDATA[
Application.alert("Hello from JavaScript macro.");
]]></script>
</macro>
JScript
Following is an example macro written using JScript:
<macro name="JScriptMacro">
<desc>Test JScript</desc>
<script type="application/x-jscript">
Application.alert("Hello from JScript Macro");
</script>
</macro>
VBScript
Following is an example macro written using VBScript:
<macro name="VBScriptMacro">
<desc>Test VBScript</desc>
<script type="text/VBScript"><![CDATA[
Dim doc
set doc=Application.activeDocument
msg = "Hello from VBScript Macro for document " + doc.documentURI
Application.alert(msg)]]></script>
</macro>