[討論] 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