เริ่มต้นใช้งาน GAS Editor

เปิด https://drive.google.com แล้ว Login คลิกปุ่ม New > Google Sheets ตั้งชื่อไฟล์: GASWS1 เมนู Tools > Script Editor เลือก Blank Project ตั้งชื่อโปรเจค : myproject1 เมนู File > New > Script File ตั้งชื่อ: myscript1 แก้ไข myFunction() ตามนี้ function myFunction() { Logger.log(“Hello World”); } เมนู File > Save หรือ กดปุ่ม Ctrl+s เมนู Run > myFunction ดูผลได้ที่ เมนู View > … Read more

Case Study: ตรวจสอบ Website Availability ด้วย Google Apps Script

เปิด Google Sheets : GASWS1 สร้าง Sheet ใหม่ ชื่อ “Log” เมนู Tools > Script Editor… เมนู File > New > Script File ตั้งชื่อ: myscript4 เขียนโค๊ดตามนี้  function check_website(url) { var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true}); return response.getResponseCode(); } function doLog(timestamp, responseCode, timeDiff) { var ss=SpreadsheetApp.getActiveSpreadsheet(); var sheet=SpreadsheetApp.setActiveSheet(ss.getSheetByName(“Log”)); sheet.appendRow([timestamp, responseCode, timeDiff]); } function getTime() { var startTime … Read more

อ่าน/เขียนข้อมูลกับ Google Sheets

เปิด Google Sheets : GASWS1 เมนู Tools > Script Editor… เมนู File > New > Script File ตั้งชื่อ: myscript3 สร้าง function insertData1() ตามนี้ function insertData1() { var ss=SpreadsheetApp.getActiveSpreadsheet(); var sheet=SpreadsheetApp.setActiveSheet(ss.getSheetByName(“Sheet1”)); sheet.getRange(1, 1).setValue(“Hello World”); sheet.getRange(“A2”).setValue(“สวัสดี”); var v1=[ [“ชื่อ”,”นามสกุล”,”อายุ”] ]; var v2=[ [“สมชาย”] ,[“Robert”] ,[“39”] ]; sheet.getRange(“A3:C3”).setValues(v1); sheet.getRange(“A4:A6”).setValues(v2); } เมนู Run > insertData1 สร้าง function insertData2() ตามนี้ function insertData2() … Read more

Google Apps Scripts Workshop – Level 1

เริ่มต้นใช้งาน GAS Editor อ่าน/เขียนข้อมูลกับ Google Sheets Case Study: ตรวจสอบ Website Availability ด้วย GAS แทนที่ข้อความ ด้วยค่าใน Google Sheets การสร้างไฟล์ PDF จากข้อความที่ต้องการ การส่งอีเมลถึงผู้รับตามที่กำหนด พร้อมแนบข้อความ/ไฟล์ที่ต้องการ การส่งไฟล์ทางอีเมลแบบ Top Secret! การแสดงผลจำนวน Quota การส่งอีเมลที่ยังเหลืออยู่ในรอบ 24 ชั่วโมง

วิธีใช้ Google Sheets ลบผู้ใช้จำนวนมากบน GAFE

[บทความนี้ สำหรับผู้ที่มี Admin Privilege ขึ้นไป] ต่อจากบทความ วิธีใช้ Google Sheets เปลี่ยนแปลงข้อมูลผู้ใช้จำนวนมากบน GAFE เมื่อต้องการลบผู้ใช้จำนวนมาก ก็ทำเหมือนเดิม แต่เปลี่ยน Script นิดหน่อยดังนี้ สร้าง Google Apps Scripts ใน Google Sheets นี้ ด้วยเมนู Tools > Script Editor … จากนั้นเลือก Blank Project แล้วกดปุ่ม Close ตั้งชื่อโปรเจค UpdateUser แล้วใส่โค๊ดดังนี้ (ปรับค่า firstRow และ lastRow ให้เหมาะสมตามต้องการ) นอกนั้นเหมือนเดิม หวังว่าจะเป็นประโยชน์ครับ