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.
For a detailed description of working with macros, please refer to the Lua Programming Language Macros Guide document.
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 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 •In the Status bar, click 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 •If there is at least one macro in the document, click 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 Click To close the Macros pane, click the |
If your document contains a large number of macros, follow the steps below to quickly find the required macro: 1.On the Sidebar, click 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. |
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 2.In the Macro Editor window, select the desired macro from the list. 3.Click 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 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 •Double-click to select the macro line. |
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 •On the Sidebar, click 2.In the Macro Editor window, make the necessary changes to the macro code. Changes to the macro code are saved automatically. |
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 •On the Sidebar, click 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 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 2.To control the debugging steps, use the following buttons:
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 Debugging is terminated when the end of the macro is reached. To interrupt the debugging process, click |
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 •On the Sidebar, click 2.In the Macro Editor window, click 3.In the window that opens, confirm the deletion of the macro. |
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 •On the Sidebar, click 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. |