简体   繁体   English

Google 表格宏副本

[英]Google Sheets Macro Copy

I am trying to create macros on Google sheets, where I create a drawing, and link it to a script so that the cell content can be copied be pressing Ctrl + C. For some reason, my code isn't working, and I can't figure it out.我正在尝试在 Google 工作表上创建宏,我在其中创建了一个绘图,并将其链接到一个脚本,以便可以按 Ctrl + C 复制单元格内容。出于某种原因,我的代码不起作用,我可以弄清楚。

    function Launch1()
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("MacroBNS");
  ss.setActiveSheet(sheet).setActiveSelection("A3");
  function copyToClipboard(text) {
  window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
}
}

Any ideas on why it isn't working?关于为什么它不起作用的任何想法?

you have function inside another function, this code doesn't work from line:您在另一个函数中有函数,此代码不能在线运行:

function copyToClipboard(text) {

Also code "window.prompt" gives error.代码“window.prompt”也给出了错误。 You could use inputBox(prompt, buttons) instead.您可以改用 inputBox(prompt, buttons) 。 Look for more information here: https://developers.google.com/apps-script/reference/base/browser在此处查找更多信息: https ://developers.google.com/apps-script/reference/base/browser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM