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

Ключ

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

Run external macro Version 4 (Net)

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

...

Description

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

Action icon

 

Action parameters

Input parameters

  1. "Context" field - a type of a Word document where the external macro will run. 
  2. "File" field – path to the macro text file containing the VBA code
  3. "Procedure name" field - name of the called function or subroutine that is specified in the VBA code of the macro.
  4. "Parameters" field - Values 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.

Settings

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

...

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

...

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

54. Customize 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:

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

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

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

Results

Macro ran successfully Image Removed