How to add custom menu items to Google Sheets using Apps Script

I’m trying to build a custom menu in Google Sheets with Apps Script but running into issues. The menu item should appear in the toolbar but it’s not showing up at all.

I’m pretty new to this stuff but need to set up some automation for my workflow. Here’s what I have so far:

function onOpen() {
    const interface = SpreadsheetApp.getUi();
    interface.createMenu("Auto Tools")
        .addItem("Execute sharing", "runSharing")
        .addToUi();
}

I thought this would create a new menu option in my Google Sheets but nothing appears when I open the file. What am I missing here? Do I need to enable something or is there a step I’m forgetting?

Your code looks fine. The issue is probably that onOpen doesn’t run right after you write it. You need to manually run it once from the Apps Script editor first. Just go to your script editor, pick onOpen from the dropdown, and hit run. Then refresh your Google Sheet - the menu should show up. Also double-check that your runSharing function actually exists, or you’ll get an error when someone clicks the menu.

hey, i had the same issue! make sure you save the script first, then try reloading the sheet. sometimes it helps to close and reopen the file from drive to get the onOpen function to trigger. good luck!

Had this exact problem when I started with Apps Script. The onOpen trigger has some quirks that caught me off guard. First, check your execution permissions - Google blocks custom functions initially for security reasons. Run the onOpen function manually from the script editor first. It’ll prompt you to authorize the script to access your sheets. No authorization = no menu. Another gotcha: onOpen triggers don’t work in incognito mode or when viewing shared sheets where you can’t edit. Open the sheet in a regular browser window with the Google account that owns the file. The menu should show up after you reload once you’ve authorized the script.

Manual triggers work, but you’ll hit this same issue every time you change your script. Apps Script gets messy fast when you’re building anything complex.

I had the same problem building workflows for my team. Apps Script locks you into Google’s world and debugging triggers is a nightmare.

Switching to Latenode changed everything for me. Skip the onOpen triggers and authorization headaches - build your menu functionality with their visual interface instead. Connect directly to Google Sheets, drag and drop your logic, and trigger it however you want.

Best part? You’re not stuck with just Google Sheets. When you need more apps later, you won’t have to rewrite everything in different languages.

I’ve built tons of workflows that started as “simple” Apps Script projects and grew into complex multi-app automations. Starting with a real automation platform saves you from these roadblocks.

You can check it out here: https://latenode.com