Google関連

[Google Apps Script]メニューの追加と確認ダイアログの表示

Google Apps Scriptで新規メニューを追加し、メニューからダイアログを表示する関数を実行してみます。
onOpen」はスプレッドシートやドキュメント、フォームが開かれたときに実行されます。

//var ui = SpreadsheetApp.getUi();
var ui = DocumentApp.getUi();

function onOpen(e){
    ui.createMenu('サンプル メニュー').addItem('ダイアログ表示', 'showAlert').addToUi();
}

function showAlert(){
    var result = ui.alert(
        'サンプルダイアログ',
        '処理を続けますか?',
        ui.ButtonSet.YES_NO);
    
    if(result == ui.Button.YES){
        ui.alert('「はい」ボタンが押されました。');
    }else{
        ui.alert('「いいえ」ボタンが押されました。');
    }
}

GoogleAppsScript_01_01

GoogleAppsScript_01_02

GoogleAppsScript_01_03

Google Docs用アドオンを作成する。前のページ

[Google Apps Script]サイドバーを表示する次のページ

関連記事

  1. Google関連

    [Google Apps Script]マクロの記録のショートカット情報の保存先

    Google スプレッドシートには、Web版ExcelのOffice …

  2. Google関連

    Google Apps Script Execution APIを試してみた。

    「「GAS Station #2」に参加してきました。」で書いた通り、…

  3. Google関連

    Google Apps Script 活用トーク #6に参加しました – #GAS活

    5月29日(金)に開催された「Google Apps Script 活…

  4. Google関連

    Google Apps Script 活用ミートアップ #4に参加しました – #GAS…

    5月20日(月)にNagatacho GRiDで開催された「【エンジニ…

  5. Google関連

    [Google Apps Script]Google アナリティクスのデータを取得する。

    拡張サービスの「Google Analytics API」を使って、G…

  6. Google関連

    [Google Apps Script]選択中のスライドに対してのみ処理を行う

    以前、Google スライドですべてのスライドに対して処理を行う方法に…

コメント

  1. この記事へのコメントはありません。

  1. この記事へのトラックバックはありません。

Time limit is exhausted. Please reload CAPTCHA.

※本ページはプロモーションが含まれています。

Translate

最近の記事

アーカイブ

PAGE TOP