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 menu, select > . •If there is at least one macro in the document, click on the Sidebar. In the Macro pane, click the button to the right of the button. In the drop-down list, select . 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 “” pops up on the screen.
3.Complete the recording in one of the following ways: •In the menu, select > . •If there is at least one macro in the document, click on the Sidebar. In the Macro pane, click the button to the right of the button. In the drop-down list, select . •In the Status bar, click . 4.In the opened dialog box, specify the macro name and click . If the macros has been successfully saved, the following pop-up message will be displayed on the screen: “”. To enter the code of a macro manually: 1.Create a new macro using one of the following methods: •In the menu, select > . In the Macro Editor window, click . •If there is at least one macro in the document, click on the Sidebar. In the Macros pane, click . 2.Enter a name for the macro or leave the default name. To save the name, press 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 button appears on the Sidebar. This button is displayed as long as there is at least one macro in the document. Click to open Macros pane. To close the Macros pane, click the button at the top of the pane, or click button on the Sidebar again. |
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 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 menu, select > . •On the Sidebar, click . In the Macro pane, click the button to the right of the button. In the drop-down list, select . 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 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 menu, select > . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macro pane, click the button to the right of the button. In the drop-down list, select . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macros pane, hover the mouse cursor over the name of the required macro and click . In the drop-down list, select . 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 menu, select > . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macro pane, click the button to the right of the button. In the drop-down list, select . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macros pane, hover the mouse cursor over the name of the required macro and click . In the drop-down list, select . 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 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 . 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: 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 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: • This area will display messages while debugging. • The calls stack area. • 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 to the left of the variable name. 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 menu, select > . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macro pane, click the button to the right of the button. In the drop-down list, select . In the Macro Editor window, select the desired macro in the list. •On the Sidebar, click . In the Macros pane, hover the mouse cursor over the name of the required macro and click . In the drop-down list, select . 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 is contained in the VBA module , select the Lua macro . To select a Lua macro, do one of the following: •In the menu, select > . In the Macro Editor window, select the required Lua macro. •On the Sidebar, click . In the Macro pane, click the button to the right of the button. In the drop-down list, select . In the Macro Editor window, select the required Lua macro. •On the Sidebar, click . In the Macros pane, hover the mouse cursor over the name of the required Lua macro and click . In the drop-down list, select . 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. |