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

ParameterDescription
ContextWord-document instance where the external macro will be run.
Macro pathPath to the text file of the macro with the VBA code.
Procedure nameThe name of the called function or subprogram that is specified in the VBA code of the macro.
Input parameterValues 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

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ContextInstance of a Word document.Robin.WordWord contextYes
Macro PathPath to a macro text file that contains VBA code.Robin.FilePath
Yes
Procedure nameThe name of the function or subroutine to call that is specified in the macro’s VBA code.Robin.String
Yes
Input parameterValues 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
ResultThe 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

  1. The "Trust access to the object model of VBA projects" checkbox must be checked in the security settings.

  2. If multiple parameters are to be specified, the user must specify a collection containing these parameters in the "Parameters" field.
  3. Parameter values must be specified in the same order in which these parameters are specified in the called function.
  4. 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

  1. Assemble a robot scheme with the actions.


  2. Set the "Open document" action parameters.


  3. Set the "Run external macro" action parameters.


  4. Set the "Save as" action parameters.


  5. 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.

  • Нет меток