A macro is a set of actions that automate repeated or time-consuming tasks in a document. MyOffice Text macros are written in Lua programming language.
Macros are most commonly used for the following purposes:
•To input data
•To find and replace data throughout the text
•To clear data
1.In the Command menu, click > . 2.In the window that appears, click . 3.Enter the new macro name or keep the default name. To keep the default name, click . Or click anywhere in the window with the mouse. 4.Enter the macro script. New macros are saved automatically. When you add a macro command to a file, the button appears on the Sidebar. Click this button to open the macro commands pane where you can perform the following actions: •Find a macro •Run a macro •Open the window To close the macro commands pane, click the button above the find and replace pane, or click on the Sidebar again. The button is displayed in the Sidebar as long as the document contains at least one macro command. |
If a file has multiple macro commands, find the macro that you need by following these steps: 1.On the Sidebar, click . 2.In the find and replace pane of the macro commands pane, specify the name of the macro that you want to find, in full or in part. The list of macro commands will display macro commands with names matching the search request. |
You can execute a macro command using the window or the macro commands operation pane. To run a macro command using the window, follow these steps: To run a macro, do the following: 1.In the Command menu, click > . 2.In the window that appears, select the macro from the list. 3.Click . The results are displayed in the pane. To run a macro using the macros pane, do the following: 1.On the Sidebar, click the button. 2.Execute the macro in one of the following ways: •In the macro commands pane, hover the mouse cursor over the macro command name and click . •Select the macro line by double-clicking it.
|
1.Open the widow in one of the following ways: •In the Command menu, click > . •On the Sidebar, click the button. On the macros pane, place the cursor over the title of the macro that you want to edit and click . 2.In the window that appears, select the macro from the list. 3.Make the necessary changes to its script. All changes made to the script are saved automatically. |
Before you start the macro debugger, set the debugger breakpoints in the macro text. To do this: 1.Open the widow in one of the following ways: •In the Command menu, click > . •On the Sidebar, click the button. On the macros pane, place the cursor over the title of the macro that you want to edit and click . 2.In the window, select the desired macro from the list. 3.Set the first debugger breakpoint. To do this, click to the right of the line number where you want to create a breakpoint. The breakpoint will be marked with the icon. 4.Set other breakpoints by repeating these actions. To delete a breakpoint, click it with the mouse. To debug a macro: 1.Click . The macro debugging process will begin. If the text of a macro contains breakpoints, the debugging process will stop on the line that contains the first breakpoint. If there are no breakpoints, the debugging process will stop at the first line of the macro. 2.To manage the debugging steps, use the following buttons: Perform one debugging step or step into the body of the function, if there is one in the current debugging position. Perform one debugging step without stepping into the body of the function. Continue executing the macro until leaving the function where the debugger is at the current position. While debugging, the window displays the following areas: • This window will display messages while debugging. • The calls stack window. • This window displays the values of local and global variables available at the current macro step. If the displayed variable is a table or an array, you can view its detailed contents by clicking the button to the left of the variable name. The debugging process ends once the end of the macro has been reached. To interrupt the debugging process, click . |
To delete a macro: 1.Open the widow in one of the following ways: •In the Command menu, click > . •On the Sidebar, click . On the macros pane, place the cursor over the title of the macro that you want to edit and click . 2.In the window that appears, select the macro from the list. 3.Click . 4.In the window that appears, confirm that you want to delete the macro. |
In MyOffice Text, running VBA macros created in Microsoft Word is not possible. However, you can view the code of the VBA macros contained in the document and rewrite them in Lua. VBA macros saved in the current Microsoft Word document are available for viewing.
To view and rewrite the VBA macro code, follow these steps: 1.Open the .docm file. 2.Select the Lua macro with the name of the VBA module that contains the desired VBA macro. For example, if VBA macro is in VBA module, select Lua macro. Do one of the following to select the Lua macro: •In the Command menu, select > . On the window, select the desired Lua macro. •On the Sidebar, click the button. On the macro pane, hover the mouse over the name of the desired Lua macro and click the button. The window will display the code of VBA macros that are contained in the corresponding VBA module. 3.Rewrite the code of the required VBA macro in Lua. 4.Close the window. 5.Save the document in .docx format using the Save as command. The changes made are not saved in the original .docm file. |