Simplify Google Apps Script Execution: How to Use Shape Buttons and Macro Imports

Google Apps Script (GAS) can help streamline your daily tasks, but have you ever found it inconvenient to run scripts directly from the GAS editor every time?

Wouldn’t it be great if you could execute GAS directly from your spreadsheet more easily and save even more time?

In this article, we’ll introduce two simple methods for running GAS directly within Google Sheets: using shape buttons and using macro imports.

TOC

Example Output

Running Google Apps Script Using Shape Buttons

Shape buttons allow for intuitive and user-friendly operation.

By clicking a shape button placed in your Google Spreadsheet, the assigned GAS script is executed immediately.

For example, you can assign a script that retrieves specific Gmail data to a button, and simply pressing the button will trigger the process.

This approach is visually intuitive, ensuring users can operate it without confusion about what the button does.

Running Google Apps Script Using Macro Imports

Easily executed from the menu.
Organize and manage multiple scripts.

From the “Extensions” > “Macros” menu, you can easily select and run pre-created Apps Scripts.

By adding frequently used scripts to the menu, you can significantly reduce the effort required for execution.

How to Execute Apps Script Using Shape Buttons

STEP
Create a Shape

Go to “Insert” > “Drawing” and select “Shape.”

From “Shapes,” select any shape (e.g., a rectangle) and draw it.

Right-click on the shape you created and select “Edit text” to add text to it.

Add clear and descriptive text to the shape.

STEP
Assign the Script

Click on the created shape, then select “Assign script” from the right-click menu or the “…” menu.

Enter the name of the script you want to execute (e.g., saveEmailsToSheet).

Now, simply clicking the shape will run the assigned script.

Script Name Location

If your script starts with function saveEmailsToSheet() {, copy the saveEmailsToSheet portion and paste it when assigning the script to the shape.

STEP
Test and Verify

Click the button on the spreadsheet to ensure the script executes as expected.

If you’re running the script for the first time, you need to authorize it.

Therefore, press “Review Permissions.

Detailed Authorization Steps

Press “Advanced.”

Press “Go to Untitled project (Unsafe).”

After that, press “Allow.”

How to Execute Apps Script Using Macro Imports

STEP
Import a Macro

In your spreadsheet, go to “Extensions” > “Macros” > “Import macro.”

Select the function you want to use from the list and click “Add function.”

The selected function will be added to the menu as a macro.

STEP
Rename a Macro

To rename a macro you’ve added, go to “Extensions” > “Macros” > “Manage macros.”

Here, click on the name of the macro you want to edit and change it to a more descriptive name.

You can also assign a shortcut key to the macro on the same screen.

By setting a shortcut key, you can execute the macro even faster.

Comparison: Shape Buttons vs. Macro Imports

Benefits of Shape Buttons
  • Intuitive and Easy to Understand
    Shape buttons are visual, making it immediately clear which script will be executed.
  • Quick Execution of Specific Tasks
    Simply pressing the button allows you to execute specific processes quickly.
Benefits of Macro Imports
  • Organizing Multiple Scripts
    If you have multiple scripts, you can organize and add them to the menu for easy management and use.
  • Easy Access from the Menu
    Scripts can be executed with a simple click from the menu, streamlining routine tasks.

Conclusion

By using the two methods introduced—Shape Buttons and Macro Imports—running Google Apps Script (GAS) becomes much simpler.

  • Shape Buttons are ideal for intuitively executing specific scripts.
  • Macro Imports are convenient for organizing and running multiple frequently-used scripts.

Other options include adding scripts to a custom menu or utilizing add-ons for even more functionality.

Choose the method that suits your workflow best and streamline your tasks for greater efficiency!

Our company offers support for improving work efficiency through the use of Google Apps Script.
If you need assistance with Google Apps Script customization or error resolution, please feel free to contact us.
We are fully committed to supporting your business improvements.

Contact us here

Let's share this post !

Comments

To comment

TOC