Run external macro Version 1 (Net)
Action group: Word
Description
The action runs a macro in a Word-document whose VBA code is specified in a separate text file.
Find more about working with macro here:
Action icon
Settings of parameters
Parameter | Description |
---|---|
Context | Word-document instance where the external macro will be run. |
Macro path | Path to the text file of the macro with the VBA code. |
Procedure name | The name of the called function or subprogram that is specified in the VBA code of the macro. |
Input parameter | Values of input parameters of the called function or subprogram in the macro code. The values of parameters must be specified in the same order in which these parameters are specified in the called function. |
Output parameters
Result - the value returned by the running macro. If the specified macro returns nothing, the result of the action will be empty.
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Context | Instance of a Word document. | Robin.Word | Word context | Yes |
Macro Path | Path to a macro text file that contains VBA code. | Robin.FilePath | Yes | |
Procedure name | The name of the function or subroutine to call that is specified in the macro’s VBA code. | Robin.String | Yes | |
Input parameter | Values of input parameters of the called function or subroutine. Parameters must be specified in the same order in which these parameters are specified in the called function. | Robin.Collection | No | |
Results | ||||
Result | The value returned by the running macro. If the specified macro does not return anything, the result of the action will be empty. | Robin.Collection |
Special conditions of use
- The "Trust access to the object model of VBA projects" checkbox must be checked in the security settings.
- If multiple parameters are to be specified, the user must specify a collection containing these parameters in the "Parameters" field.
- Parameter values must be specified in the same order in which these parameters are specified in the called function.
- Russian language is not supported in the macro (function) name.
Example of use
Task
There is a Word-document.
Run an external macro ReplaceEwithYo.bas in this document:
ReplaceEwithYo
Sub ReplaceEwithYo() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "Е" .Replacement.Text = "Ё" .Forward = True .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub
Solution
Use the "Open document", "Run external macro", "Save as" actions.
Implementation
- Assemble a robot scheme with the actions.
- Set the "Open document" action parameters.
- Set the "Run external macro" action parameters.
- Set the "Save as" action parameters.
- Click "Start" in the top panel.
Result
The action runs an external macro in the Word-file, whose VBA code is specified in a separate text file.
Обзор
Инструменты контента