Created
September 8, 2020 01:14
-
-
Save kinuasa/36756f866c26bd8a5a2bd695df9b9f62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//シートの保護とユーザーに許可する操作設定 | |
function main(workbook: ExcelScript.Workbook) { | |
const pw = "pass"; //保護パスワード | |
let sheet = workbook.getActiveWorksheet(); | |
let wsp = sheet.getProtection(); | |
if (wsp.getProtected() === true) { | |
wsp.unprotect(pw); //シートの保護解除 | |
} else { | |
//ユーザーに許可する操作設定 | |
let opt = wsp.getOptions(); | |
opt.allowFormatCells = false; //セルの書式設定 | |
opt.allowFormatColumns = false; //列の書式設定 | |
opt.allowFormatRows = false; //行の書式設定 | |
opt.allowInsertColumns = false; //列の挿入 | |
opt.allowInsertRows = false; //行の挿入 | |
opt.allowInsertHyperlinks = false; //ハイパーリンクの挿入 | |
opt.allowDeleteColumns = false; //列の削除 | |
opt.allowDeleteRows = false; //行の削除 | |
opt.allowSort = false; //並べ替え | |
opt.allowAutoFilter = true; //オートフィルターの使用 | |
opt.allowPivotTables = false; //ピボットテーブルとピボットグラフを使う | |
opt.allowEditObjects = false; //オブジェクトの編集 | |
opt.allowEditScenarios = false; //シナリオの編集 | |
opt.selectionMode = ExcelScript.ProtectionSelectionMode.none; //すべてのセルの選択不可 | |
wsp.protect(opt, pw); //シートの保護 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment