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]insertTextBoxメソッドでスライドにテキストボック…

    昨年の9月にスライド上にテキストボックスを挿入するスクリプトについて記…

  2. Office関連

    Gmail APIを使ってメール送信するVBAマクロ(3)

    前回、前々回とGmail APIを扱ってきましたが、今回は前々回の記事…

  3. Google関連

    [Google Apps Script]選択文字列を翻訳する

    Google Apps Scriptでドキュメント上で選択している…

  4. Excel

    Google スライドで新規プレゼンテーションを作成するVBAマクロ

    ここ数日PowerPointのマクロに加え、Google Apps S…

  5. Power Automate for desktop

    [Power Automate Desktop]Google Driveにファイルをアップロードする…

    前々回の記事でGoogle Drive APIの実行に必要なアクセスト…

コメント

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP