[讨论] google scipt被阻挡

楼主: seft584f8 (seft584f8)   2023-03-03 15:36:24
最近接了一个案子
在google sheet 的扩充功能内可以选Apps Script
打开后虽然中文标示录制宏, 但估计是google翻译错文字
应该就是google script editor
照客户需求编写了这段代码
function myFun_onclick123123321321() {
// Step 1: Get the position of the current cell (row, col)
var sheet = SpreadsheetApp.getActiveSheet();
var cell = sheet.getActiveCell();
var row = cell.getRow();
var col = cell.getColumn();
// Step 2: Use VLOOKUP to get the value of the target cell in table2
var table2Sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("table2");
var lookupRange = table2Sheet.getRange("A:M");
var lookupValue = sheet.getRange(row + 4, col).getValue();
var columnIndex = 6; // You may need to adjust this depending on which
column you want to look up
var targetCell = SpreadsheetApp.functions.vlookup(lookupValue, lookupRange,
columnIndex, false);
// Step 3: If the value of the target cell in table2 is greater than 0,
decrement it by 1
if (targetCell.getValue() > 0) {
targetCell.setValue(targetCell.getValue() - 1);
}
}
代码应该不是重点, 不过总之我点执行尝试看看是否有bug时,
出现一个视窗: 需要授权
我选审查验证之后需要重新登入google帐号
登入后出现以下文字:
系统已封锁这个应用程式
这个应用程式尝试存取您 Google 帐户中的机密资讯。为保护您的帐户,Google 已阻挡
这个存取行为。
( 我把code简短到什么都没写也会出现此讯息)
请问大大知道怎么让google scrip写好后可以使用吗?
作者: LoveMoon (我不是魔兽三国作者.....)   2023-03-03 20:33:00
google it: Apps Script This app is blocked
楼主: seft584f8 (seft584f8)   2023-03-04 14:37:00
已经解决 谢谢

Links booklink

Contact Us: admin [ a t ] ucptt.com