Run macro Version 1 (Net)

Action group: Word 


Description

The action runs the specified macro in the Word-document.

More about interacting with macro:

Action icon

Settings of parameters

ParameterDescription
ContextWord-document instance where the macro will be run.
Macro nameName of the macro that will be run.

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ContextThe instance of the Word document.Robin.WordWord contextYes
Macro nameThe name of the macro to be run.Robin.String
Yes

Special conditions of use

The macro must be created in Word beforehand.

To begin, create a Word-document.

To do this:

  • Open MS Word, go to "File" and then "Parameters".
  • In the open window "Word parameters" click on "Customize feed".
  • Scroll down the list and check the checkbox "Developer".
  • In the toolbar go either to the "Developer" tab or to the "Macros" tab - there you can run built-in (created) macros inside the document. In the "Visual Basic" tab you can create new macros.
  • Click on the 3rd tab to get to the panel for creating macros.
  • Click right mouse button on the 1 element, select Insert -> Module.

This way you can either create your own macro or paste a ready-made one into this field and save it using CTRL+S.    

Example of use

Task

There is a Word-document:

Run macro that swaps words.

ReplaceИзбаWithДом
Sub ReplaceИзбаWithДом()
    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 Macro", "Save as" actions.

 Реализация 

  1. Assemble a robot scheme with the actions:                                                        
  2. Move the "Open document" action to the workspace.


  3. Move the "Run Macro" action to the workspace.
     

  4. Move the "Save as" action to the workspace.


  5. Move the "Close document" action to the workspace. 


  6. Click "Start" in the top panel to start the robot.

Result

The program robot completed successfully.

The document contains the result of the macro execution.

  • Нет меток