当用户在图纸之间切换时触发 [英] Trigger when user switches between sheets

查看:64
本文介绍了当用户在图纸之间切换时触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当用户在Google表格电子表格中的表格之间切换时,是否有办法运行脚本?

Is there a way on to run a script whenever the user switches between sheets in a Google Sheets Spreadsheet?

或多或少像 onOpen ,但它不会在打开文档时运行,而是应在用户每次切换到另一张纸时触发。

More or less like onOpen, but instead of running when the document is opened, it should fire every time the user switches to another sheet.

推荐答案

更新:在 2020年4月上,Google添加了 onSelectionChange(e),可用于检查用户是否在工作表之间切换,也称为标签。

UPDATE: On April 2020 Google added onSelectionChange(e) which could be used to check if the user switched between sheets aka tabs.

目前,没有与将一张纸切换到另一张纸相关的触发器。要了解Google Apps脚本中的可用触发器,请签出触发器和事件-Google Apps脚本指南

At this time there isn't a trigger related to switch for one sheet to another. To learn about the available triggers in Google Apps Script, please checkout Triggers and events - Google Apps Script Guides

作为一种解决方法,您可以使用自定义菜单,然后 SpreadsheetApp.setActivesheet 通过使用脚本而不是使用选项卡,而是在脚本中包括从一张纸切换到另一张纸时要运行的函数的调用。

As a workaround you could a custom menu to and SpreadsheetApp.setActivesheet to switch between sheets by using a script instead of using tabs and including in that script a call to the function to be run when switching from one sheet to another.

这篇关于当用户在图纸之间切换时触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆