A macro is a set of actions that automate repeated or time-consuming tasks in a document. "MyOffice Spreadsheet" macros are written in Lua programming language.

Macros are most commonly used for the following purposes:

Add a formula in a cell.

Add text in a cell.

Find and replace items throughout the text.

Delete text.

Saving macros is only available:

In .xods and .ods files. Saving documents in the .xlsx format will automatically delete the macros.

Within the current spreadsheet. To use a macro in other spreadsheets, create them directly in these spreadsheets.

Create a macro

To create a macro:

1.On the Tools menu, select Edit Macros.

2.In the opened window, click macros_add_script_icon.

3.Enter the new macro name or keep the default name. To keep the default name, click Enter. Or click anywhere in the Edit Macros window using the mouse.

4.In the editing pane, enter the macro script.

New macros are saved automatically.

When you add a macro command to a document, the side_panel_macro (Macros) button appears on the Sidebar. Clicking this button opens the macro commands pane, where you can perform the following actions:

Find a macro.

Run a macro.

Open the macro editing window.

To close the macro commands pane, click the side_panel_macro_close button above the search bar, or click the side_panel_macro (Macros) button on the Sidebar again.

The side_panel_macro (Macros) button is displayed in the Sidebar as long as the document contains at least one macro command.

Find a macro

If the document contains a large number of macro commands, perform the following steps to quickly find the desired macro command:

1.On the Sidebar, click the side_panel_macro (Macros) button.

2.On the macro commands pane, specify a part of the name or the whole name of the required macro command in the search line.

The list of macro commands will display macro commands whose names satisfy the specified search results.

Run a macro

To run a macro, follow the steps below:

1.On the Tools menu, select Edit Macros.

2.In the opened window, select the macro from the list.

3.Click the Run button.

The results are displayed in the Output pane.

To run a macro using the macros pane, do the following:

1.On the Sidebar, click the side_panel_macro (Macros) 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 clip0001 (Run)

Select the macro line by double-clicking it.

Edit a macro

To edit a macro:

1.On the Tools menu, select Edit Macros.

2.In the opened window, select the macro from the list.

3.Edit the macro script as needed.

All changes made to the script are saved automatically.

Debug a macro

Before you start the macro debugger, set the debugger breakpoints in the macro script. To do this:

1.Open the macro editing widow in one of the following ways:

On the Command menu, click Tools > Edit Macros.

On the Sidebar, click the clip0002 (Macros) button. On the macros pane, place the pointer over the title of the macro that you want to edit and click the clip0003(Edit) button.

2.In the Macros Editor 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 macros_breakpoint 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 macros_debug (Debug) button. The macro debugging process will begin. If the script 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:

macros_step_into : Perform one debugging step or step into the body of the function, if there is one in the current debugging position.

macros_step_over : Perform one debugging step without stepping into the body of the function.

macros_step_out : Continue executing the macro until leaving the function where the debugger is at the current position.

While debugging, the Macros Editor window displays the following areas:

In progress...: This window will display messages while debugging.

Calls Stack: The calls stack window.

Variables: 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 macros_variable 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 the macros_stop (Break script) button.

Delete a macro

To delete a macro, follow the steps below:

1.Open the macro editing widow in one of the following ways:

On the Command menu, click Tools > Edit Macros.

On the Sidebar, click the clip0002 (Macros) button. On the macros pane, place the pointer over the title of the macro that you want to edit and click the clip0003(Edit) button.

2.In the opened window, select the macro from the list.

3.Click macros_delete_script_icon.

4.In the opened window, confirm that you want to delete the macro.

Was the material useful?
Yes
No
Users found this material useful: 0 из 0