Call

Syntax

[Call] [MacroName][.][SubName] [ArgumentList]

Remarks

Transfers control to a subroutine in the running macro or another macro. To specify a subroutine in another macro, use the syntax MacroName.SubName. If SubName is not specified, the Main subroutine in MacroName runs. Call is optional; it can help distinguish subroutine names from WordBasic keywords when you read and edit macros. Each variable in the comma-delimited ArgumentList must correspond to a value that the subroutine being called is prepared to receive.

Note

When you call another macro, Word looks for the macro in available templates in the following order: the template containing the Call instruction, the active template, the Normal template, and loaded global templates. For example, suppose USER.DOT and NORMAL.DOT both contain a DisplayMessage macro. The following macro in USER.DOT:


FileNew .Template = "Normal"
DisplayMessage

runs the DisplayMessage macro in USER.DOT, even though a document based on NORMAL.DOT is active when the Call instruction is run.

For more information about using subroutines, including how to share variables and pass arguments between subroutines, see Chapter 4, "Advanced WordBasic," in Part 1, "Learning WordBasic."

Example

This example calls the subroutine FindName twice; each line, with or without Call, has the same effect:


Call FindName        'Transfer control to the subroutine FindName
FindName                'Transfer control to the subroutine FindName

See Also

Sub¼End Sub