Appendix III - Macro samples Wordfast Classic

From Wordfast Wiki
Revision as of 21:32, 1 October 2017 by Samar (talk | contribs) (Created page with "''Note: '''the Wordfast Knowledge Base''', accessible from http://www.wordfast.net has more contents on this topic.'' '''About all macros entered with Pandora's Box "Macro......")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: the Wordfast Knowledge Base, accessible from http://www.wordfast.net has more contents on this topic.

About all macros entered with Pandora's Box "Macro..." commands

(PC only): if instead of a macro name, you enter "Keys=" followed by a string of text similar to the one described in the Dictionary keys section, then Wordfast will execute the keystrokes you have defined. For example, using

Keys=L&H;^a{Delete}{SourceSegment}{Home}%tt{Ms-Word}

in conjunction with the English version of L&H's Power Translator 7 text-to-speech function, will read aloud your source segment at the time it is presented for translation.

Creating macros

Macros should normally be entered in Normal.dot. To do so: in Ms-Word, use Tools/Macro/Visual basic editor (or press Alt+F11) to open the VBA window. In the left side of the window, double-click "Normal". If there is no module, use the Insert menu to add a module. Usually, a new module called "Module1" is added. Double-click it. A window should open to the right: this is where you should copy-paste the macros given below, and edit them as needed. These macros will be saved with Normal.dot when you exit Ms-Word.

The Wordfast hotline does not offer support on VBA and macros. Refer to your Ms-Word manual, or to literature on the subject.

In Wordfast/PB/Macro..., you should enter "Normal.Module1.CheckLength" if, for example, you want to try the first macro described below (either as a QA macro, or as a post-segmentation macro).

To associate a macro with a shortcut: use the View/Toolbars/Customise menu. Click "Keyboard". In the leftmost list, choose "Macros" as category. In the righmost list, click the macro name. Enter the Shortcut in the textbox, then click "Assign". Close the dialog box.

You should refrain from using the following statements or instructions in macros you intend to use with Wordfast:

End (this ends all VBA processes, including Wordfast). You can use End in a "MacroMaiden" macro to stop a translation session from being started on certain conditions.

Close (Close followed by a file number opened by you is all right, but Close alone closes all opened I/O files, including Wordfast's)

Reset (closes all opened I/O files, including Wordfast's)

If you need to open and close I/O files on disk, remember to use the FreeFile() function to ask VBA for an available I/O file number. Otherwise, your macro may conflict with a file already in use by Wordfast.

If you want your QA or post-segmentation macro to refuse to validate the segment and prompt the user to correct the translation, your macro should add a "WfStop" bookmark anywhere in the document (simply insert a Selection.Bookmarks.Add "WfStop" instruction before ending the macro). If Wordfast finds such a bookmark, it will cancel segment validation, remove the bookmark and take the user back to the target segment.

Back to Wordfast Classic User Manual