How can we help you?
Product:
Application: Table Desktop version

Macros are small programs that help to automate lengthy or frequently repeated operations in a document. MyOffice Spreadsheet macros are written in Lua programming language.

Saving macros is only available within the current document. If you want to use similar macros in another document, create them directly in the other document.

For a detailed description of working with macros, please refer to the Lua Programming Language Macros Guide document.

Create a macro

You can create a macro in one of the following ways:

Record a sequence of actions that a macro should consist of.

Enter the macro code manually.

To record a macro, do the following:

1.Start recording in one of the following ways:

In the Tools menu, select Macros > Record Macro (beta).

If there is at least one macro in the document, click side_panel_macro Macros on the Sidebar. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Record Macro (beta).

2.Perform a sequence of actions that a macro should consist of.

In the current version of the application, not all user actions are available for recording. When you perform an action that cannot be recorded, the message “Action cannot be recorded” pops up on the screen.

3.Complete the recording in one of the following ways:

In the Tools menu, select Macros > Stop Recording.

If there is at least one macro in the document, click side_panel_macro Macros on the Sidebar. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Stop Recording.

In the Status bar, click status_bar_macro_stop_recording Stop Recording.

4.In the opened dialog box, specify the macro name and click OK.

If the macros has been successfully saved, the following pop-up message will be displayed on the screen: “"Macro_name" macro saved”.

To enter the code of a macro manually:

1.Create a new macro using one of the following methods:

In the Tools menu, select Macros > Macro Editor. In the Macro Editor window, click macros_add_script_icon.

If there is at least one macro in the document, click side_panel_macro Macros on the Sidebar. In the Macros pane, click New Macro.

2.Enter a name for the macro or leave the default name. To save the name, press Enter or click anywhere in the Macro Editor.

3.Enter the code of the macro.

The code of the macro will be saved automatically.

When you add the first macro to your document, the side_panel_macro Macros button appears on the Sidebar. This button is displayed as long as there is at least one macro in the document.

Click side_panel_macro Macros to open Macros pane.

To close the Macros pane, click the side_panel_macro_close button at the top of the pane, or click side_panel_macro Macros button on the Sidebar again.

Find a macro

If your document contains a large number of macros, follow the steps below to quickly find the required macro:

1.On the Sidebar, click side_panel_macro Macros.

2.In the Macros pane, enter a part of the name or the whole name of the required macro in the search bar.

The list of macros will display macros whose names match the specified search results.

Run a macro

You can run a macro using the Macro Editor or the Macro pane. You can also create buttons in the Favorites section of the Toolbar to quickly run frequently used macros.

To run a macro using the Macro Editor, follow the steps below:

1.Open the Macro Editor in one of the following ways:

In the Tools menu, select Macros > Macro Editor.

On the Sidebar, click side_panel_macro Macros. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Open Editor.

2.In the Macro Editor window, select the desired macro from the list.

3.Click macros_run Run.

Information about the macro run result will be displayed in the Output area.

To run a macro using the Macros pane, follow the steps below:

1.On the Sidebar, click side_panel_macro Macros.

2.Run a macro in one of the following ways:

In the Macros pane, hover the mouse cursor over the name of the macro and click side_panel_macro_execute Run.

Double-click to select the macro line.

Edit a macro

To edit a macro, follow these steps:

1.Select a macro in one of the following ways:

In the Tools menu, select Macros > Macro Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Open Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macros pane, hover the mouse cursor over the name of the required macro and click side_panel_macro_more More. In the drop-down list, select Edit.

2.In the Macro Editor window, make the necessary changes to the macro code.

Changes to the macro code are saved automatically.

Debug a macro

Before you run the macro debugger, set the debugger breakpoints in the macro code. To do this, proceed as follows:

1.Select the required macro in one of the following ways:

In the Tools menu, select Macros > Macro Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Open Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macros pane, hover the mouse cursor over the name of the required macro and click side_panel_macro_more More. In the drop-down list, select Edit.

2.Set the first debugger breakpoint. To do this, click to the right of the line number where you want to toggle a breakpoint. The breakpoint will be marked with the macros_breakpoint icon.

3.Toggle other breakpoints by repeating these actions.

To delete a breakpoint, click it with the mouse.

To debug a macro, follow the steps below:

1.Click macros_debug Debug. The macro debugging process will start. If the macro code contains breakpoints, the debugging process will stop at 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 control the debugging steps, use the following buttons:

macros_step_into 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 Step Over: Perform one debugging step without stepping into the body of the function.

macros_step_out Step Out: Continue running the macro until leaving the function where the debugger is at the current position.

During debugging, the following areas are displayed in the Macro Editor window:

In progress: This area will display messages while debugging.

Calls Stack: The calls stack area.

Variables: This area displays the values of local and global variables available at the current step of macro running. If the displayed variable is a table or an array, you can view its detailed contents by clicking macros_variable to the left of the variable name.

Debugging is terminated when the end of the macro is reached.

To interrupt the debugging process, click macros_stop Stop Macro.

Delete a macro

To delete a macro, follow these steps:

1.Select a macro in one of the following ways:

In the Tools menu, select Macros > Macro Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Open Editor. In the Macro Editor window, select the desired macro in the list.

On the Sidebar, click side_panel_macro Macros. In the Macros pane, hover the mouse cursor over the name of the required macro and click side_panel_macro_more More. In the drop-down list, select Edit.

2.In the Macro Editor window, click macros_delete_script_icon.

3.In the window that opens, confirm the deletion of the macro.

View VBA macro code

You cannot run VBA macros created in Microsoft Excel in MyOffice Spreadsheet. But you can view the code of the VBA macros contained in the document and rewrite them in Lua language.

VBA macros saved in “This spreadsheet” are available for viewing.

To view and rewrite the VBA macro code, follow these steps:

1.Open an .xlsm or .xlsb document.

2.Select the Lua macro with the name of the VBA module that contains the required VBA macro. For example, if the VBA macro Macro1 is contained in the VBA module Module1, select the Lua macro Module1. To select a Lua macro, do one of the following:

In the Tools menu, select Macros > Macro Editor. In the Macro Editor window, select the required Lua macro.

On the Sidebar, click side_panel_macro Macros. In the Macro pane, click the side_panel_macro_expand button to the right of the New Macro button. In the drop-down list, select Open Editor. In the Macro Editor window, select the required Lua macro.

On the Sidebar, click side_panel_macro Macros. In the Macros pane, hover the mouse cursor over the name of the required Lua macro and click side_panel_macro_more More. In the drop-down list, select Edit.

3.The Macro Editor window will display the code of the VBA macros that are contained in the corresponding VBA module. Rewrite the code of the required VBA macro in the Lua language.

4.Close the Macro Editor window.

5.Save the document in .xlsx format using the Save As command.

Changes made are not saved in the original .xlsm or .xlsb document.

Was this helpful?
Yes
No
Next
Extensions