Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Run external macro Version 4 (

...

Net)

Группа действий: Excel 

Действие запускает в Excel-файле макрос, VBA-код которого указан в отдельном текстовом файле. 

Иконка действия

Image Removed  

Параметры действия

Входные данные

  1. Поле “Контекст” - Экземпляр Word-документа, в котором будет запущен внешний макрос.
  2. Поле “Файл” – Путь к текстовому файлу макроса, который содержит VBA-код
  3. Поле “Имя процедуры” - Имя вызываемой функции или подпрограммы, которая указана в VBA-коде макроса.
  4. Поле “Параметры” - Значения входных параметров вызываемой функции или подпрограммы в коде макроса. Значения параметров необходимо указывать в том же порядке, в каком эти параметры указаны в вызываемой функции.

Настройки

...

Свойство

...

Англ. наименование

...

Описание

...

Тип

...

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

...

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

...

Context

...

File

...

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

...

Robin.FilePath

...

Procedure name

...

...

Description

The action starts macro in an Excel file that has its VBA-code in a separate text file. 

Action icon

Image Added  

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ContextAction context for working with an Excel document.Robin.ExcelExcel contextYes
PathToFilePath to the macro text file containing the VBA code.Robin.FilePath
Yes
Procedure nameName of the called function or subroutine that is specified in the VBA code of the macro.Robin.String
Yes
ParametersValues of the input parameters of the called function or subroutine in the macro code. If it is necessary to specify several parameters, the user must specify in this field a collection containing these parameters. Parameter values must be specified in the same order in which these parameters are specified in the called function.Robin.Object
No
Results
ResultValue returned by the running macro. If the specified macro returns nothing, the result of the action will be empty.Robin.Object

Special conditions of use

To be able to run the external macro, it is important to take the following actions

  1. Open Excel options.
  2. Choose "Trust Center".
  3. Click the "Trust Center Settings" button.
  4. In the new window choose "Macro Settings".
  5. Check the

...

Result

...

Особые условия использования

Чтобы запуск внешних макросов был возможен, следует выполнить следующие действия:

  1. Открыть Excel options.
  2. Выбрать "Trust Center".
  3. Нажать на кнопку "Trust Center Settings".
  4. В открывшемся окне выбрать "Macro Settings".
  5. Поставить галочку напротив пункта "Trust access to the VBA project object model" (если не установленаsetting (If it is not checked).

Если необходимо указать несколько параметров, пользователь должен указать в  поле "Параметры" коллекцию, содержащую эти параметры. Значения параметров необходимо указывать в том же порядке, в каком эти параметры указаны в вызываемой функции.

Русский язык не поддерживается в названии  макроса (функции).

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

Задача

Есть Excel - документ.

Image Removed

Необходимо проверить актуальность дат в столбце дата по текущему месяцу. В случае если дата не актуально пометить красным цветом. Также необходимо вывести в диалоговое окно количество неактуальных дат.

Решение

Для реализации действия нужны следующие действия - "Открыть", "Запустить внешний макрос", “Сообщение”, “Сохранить”, “Закрыть”.

Реализация

  1. Собрать схему робота, состоящего из действий:

Image Removed

2. Укажем параметры в действии “Открыть 1”.

Image Removed

3. Укажем параметры в действии “Запустить внешний макрос”

Image Removed

4. Подробнее по созданию макроса можно узнать здесь: Создание макросов.

If it is necessary to specify several parameters, the user must specify in the "Parameters" field the collection containing these parameters. Parameter values must be specified in the same order in which these parameters are specified in the called function.

The Russian language is not supported in the macro name (name of the function). 

Example of use

Task

Given: an Excel document

Image Added

Check the relevance of dates in the date column for the current month. In case the date is irrelevant, mark it in red color. Also display the number of irrelevant dates in the dialog box.

Solution

Use the following actions - "Open", "Run external macro", “Show message”, “Save”, “Close”.

Implementation

  1. Assemble a robot scheme consisting of actions:

Image Added

2. Set the parameters in the "Open 1" action.

Image Added

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

Image Added

Learn more about creating a macro here: Create or run a macro.

Example of a macro

...

Блок кода
languagevb
linenumberstrue
Function TestMonth() As Long
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim currentMonthYear As String
    Dim cell As Range
    Dim counter As Long
    Set ws = ActiveSheet
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    currentMonthYear = Format(Now, "MM.YY")
    counter = 0
    For Each cell In ws.Range("A1:A" & lastRow)
        Dim cellMonthYear As String
        cellMonthYear = Format(cell.Value, "MM.YY")
        If cellMonthYear <> currentMonthYear Then
            counter = counter + 1
            cell.Interior.Color = RGB(255, 0, 0)
        End If
    Next cell
    TestMonth = counter
End Function

5. Настроить параметры действия “Сообщение”. Для того чтобы отобразить количество неактуальных дат необходимо передать результат макроса в параметр действия “Сообщение” в поле “Текст сообщения”:

Image Removed

6. Укажем параметры в действии “Сохранить”

Image Removed

7. Укажем параметры в действии “Закрыть”

Image Removed

8. Нажмем на кнопку “Старт” и посмотрим результат

Результаты

Макрос успешно отработал

4. Set the parameters of the "Show message" action. In order to display the number of irrelevant dates it is necessary to pass the result of the macro to the "Show message" action parameter in the "Message Text" field:

Image Added

5. Set the parameters in the "Save" action.

Image Added

6. Set the parameters in the "Close" action.

Image Added

7. Click the "Start" button and see the result. 

Results

Macro ran successfully Image Removed