How to create custom keyboard shortcuts for google app script functions?

后端 未结 9 1471
灰色年华
灰色年华 2020-12-04 12:10

I\'m trying to get a sense of the viability of replacing some of my Microsoft Excel spreadsheets with Google Doc Spreadsheets. How can I create a custom keyboard shortcut t

相关标签:
9条回答
  • 2020-12-04 12:52

    Great news :) You can achieve custom keyboard shortcuts for google app script functions following next easy steps:

    1. In the Google Sheets UI, select Tools > Macros > Record Macro.
    2. Record any action. For instance, change the color background in A1. Press Save.
    3. Save it with a random title and the preferred shortcut. You can change it later.
    4. Select Tools > Script editor to open the script bound to the sheet in the Apps Script editor.
    5. In the new editor tab, select View > Show Manifest File
    6. TA - DÁ! :D Change the functionName value to the desired one ;)

    Remember macro functions should take no arguments and return no values. More info at https://developers.google.com/apps-script/guides/sheets/macros#importing_functions_as_macros

    0 讨论(0)
  • 2020-12-04 12:53

    Long story short: write an html service which uses a key press event handler to capture keypress events and compares them to the hotkey shortcuts you want then calls the appropriate sub routine on the server side in apps script to inline the called for keystrokes, format or document changes.

    As far as viability goes, not as easy as the vba you are already familiar with but once you get past the different way of doing things not really that terribly difficult.

    0 讨论(0)
  • 2020-12-04 12:55

    Very recently (April 2018) Google launched a macro recorder that includes a way to assign a keyboard shortcut to fire a macro and a way to import existing scripts as macros. See Google Sheets Macros

    NOTE: This feature is currently being rolled out so it could take few weeks to be available for all. In my case it was available first on my personal Google account and since yesterday it is available on one of my G Suite accounts.

    0 讨论(0)
提交回复
热议问题