Вы просматриваете старую версию данной страницы. Смотрите текущую версию.

Сравнить с текущим просмотр истории страницы

« Предыдущий Версия 4 Следующий »

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

Create and run macro

How to create macro in Word

Programming basics

Action icon

Parameters

Input 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

Свойство

Описание

Тип

Пример заполнения

Обязательность заполнения поля

Параметры

Контекст

Экземпляр Word-документа, в котором будет запущен внешний макрос.

Robin.Word


Да

Путь к макросу

Путь к текстовому файлу макроса, который содержит VBA-код.

Путь к файлу


Да

Имя процедурыИмя вызываемой функции или подпрограммы, которая указана в VBA-коде макроса.Строка
Да
Входной параметрЗначения входных параметров вызываемой функции или подпрограммы в коде макроса. Значения параметров необходимо указывать в том же порядке, в каком эти параметры указаны в вызываемой функции.Коллекция
Нет
Результаты
РезультатЗначение, возвращаемое запущенным макросом. Если указанный макрос ничего не возвращает, результат работы действия будет пустым.Коллекция

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.

  • Нет меток