Returns the UI object used to build menus and show dialogs in Sheets.
class SpreadsheetApp method .getUi()
SpreadsheetApp is the Apps Script service.
.getUi() is the method name you will see after a dot in your code.
What it does
Why it's used
- Add custom menus, sidebars, and dialogs to the spreadsheet toolbar.
- Required before createMenu or showSidebar will show anything.
Common errors
- Forgetting parentheses on getUi. Write SpreadsheetApp.getUi(), not SpreadsheetApp.getUi or getUi by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getUi().
- Adding spaces where they do not belong. Write SpreadsheetApp.getUi(), not SpreadsheetApp .getUi(), SpreadsheetApp.getUi (), or SpreadsheetApp . getUi().
- Wrong capitalization. Use SpreadsheetApp and getUi, not spreadsheetapp or getui.
11 Snippets using this methods
- Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
- Automate Move Blank Rows
- Automatically Align Top
- Automatically Clear Content | Refresh Reuse Recycle Templates
- Automatic Calculations
- Add Columns Automatically
- Add Tasks to Google Tasks From Google Sheets
- Advanced Coding in Google Sheets for Programmers
- Americano Tournament Template With Four Automations
- Access Free API's with Google Sheets
- Activate A Certain Sheet When Opening a Spreadsheet
Explore
Related methods
-
.addToUi()
Publishes a custom menu to the spreadsheet UI.
-
.createMenu()
Builds a custom menu in the spreadsheet toolbar.
-
.showModelessDialog()
Opens a dialog the user can use while still working in the sheet.
-
.showModalDialog()
Opens a modal dialog that blocks interaction with the sheet.
-
.showSidebar()
Opens a custom sidebar built with HtmlService.
More Apps Script
12 Better Sheets tutorials
Access Free API's with Google Sheets
Activate A Certain Sheet When Opening a Spreadsheet
Add Columns Automatically
Add Tasks to Google Tasks From Google Sheets
Advanced Coding in Google Sheets for Programmers
Americano Tournament Template With Four Automations
Automate Emails
Automate Move Blank Rows
Automatically Align Top
Automatically Clear Content | Refresh Reuse Recycle Templates
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
Related blog posts
Written guides about SpreadsheetApp.getUi().
How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →Explore Coding in Google Sheets
Did you know you can actually code in Google Sheets?
Read post →