ตรวจสอบว่ามาโคร VBA เข้ากันได้หรือไม่
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ระบบจะถือว่าไฟล์ Excel ที่มีมาโคร Visual Basic for Applications (VBA)
เข้ากันได้หาก API ทั้งหมดที่ใช้ในมาโครมีฟังก์ชันที่เทียบเท่ากันโดยตรงใน Apps
Script หากมาโครไม่สามารถใช้งานร่วมกันได้อย่างสมบูรณ์ คุณอาจใช้
วิธีแก้ปัญหาหรือปรับโค้ดเพื่อให้มาโครทำงานร่วมกับ Apps Script ได้
ใช้รายงานความเข้ากันได้ของตัวแปลงมาโครเพื่อดูว่าคุณสามารถ
แปลงไฟล์โดยอัตโนมัติได้เลยหรือไม่ หรือต้องปรับ
โค้ด
เมื่อสร้างรายงานความเข้ากันได้ ระบบจะใช้สถานะใดสถานะหนึ่งต่อไปนี้กับไฟล์และ API แต่ละรายการ
สถานะ |
คำจำกัดความ |
รองรับอย่างแน่นอน |
ไฟล์เหล่านี้มี API ที่เทียบเท่ากับ API ใน Apps
Script โดยตรง |
รองรับด้วยวิธีแก้ปัญหา |
ไฟล์เหล่านี้มี API อย่างน้อย 1 รายการที่สามารถรองรับได้ด้วย
วิธีแก้ปัญหา |
ต้องตรวจสอบเพิ่มเติม |
ไฟล์เหล่านี้มี API อย่างน้อย 1 รายการที่คุณต้องตรวจสอบเพื่อ
พิจารณาวิธีดำเนินการต่อ เช่น อาจไม่มี API ที่เทียบเท่า
หรือตัวแปลงมาโครอาจไม่ได้กำหนด API ที่ใช้งาน |
สร้างรายงานความเข้ากันได้
- เปิด Google ไดรฟ์ในคอมพิวเตอร์
- ในแผงด้านขวา ให้คลิกส่วนเสริมตัวแปลงแมโคร
หากไม่เห็นแผงด้านข้าง ให้คลิกแสดงแผงด้านข้าง chevron_left ที่ด้านขวาล่าง
- คลิกเพิ่มไฟล์และโฟลเดอร์ ตัวแปลงมาโครจะรู้จักเฉพาะไฟล์ Excel
- เลือกไฟล์หรือโฟลเดอร์ที่ต้องการวิเคราะห์ แล้วคลิกเลือก เลือกไฟล์ครั้งละไม่เกิน 2,000 ไฟล์
- หากต้องการเปลี่ยนตำแหน่งที่จะบันทึกรายงานความเข้ากันได้ ให้คลิกเปลี่ยน
โฟลเดอร์ปลายทาง edit แล้วเลือก
โฟลเดอร์ที่ต้องการ มิเช่นนั้น ระบบจะบันทึกไว้ในโฟลเดอร์ไดรฟ์ของฉัน
- คลิกสร้างรายงาน
- เมื่อการวิเคราะห์เสร็จสมบูรณ์แล้ว ให้คลิกดูรายงาน
ตรวจสอบรายงานความเข้ากันได้
ใช้รายละเอียดในรายงานความเข้ากันได้เพื่อช่วยคุณตัดสินใจว่าจะดำเนินการอย่างไรต่อ
กับการแปลงไฟล์ รายงานประกอบด้วยส่วนต่อไปนี้
นอกจากนี้ คุณยังตรวจสอบรายงานแบบ API ต่อ API ได้โดยใช้ชีตที่ชื่อว่า
API ที่ต้องตรวจสอบและ API ที่มีวิธีแก้ปัญหา
กำหนดวิธีดำเนินการต่อ
คำแนะนำสำหรับแต่ละสถานะมีดังนี้
สถานะ |
คำแนะนำ |
รองรับอย่างแน่นอน |
คุณจะจำลองตรรกะเดียวกันจาก VBA API ใน Apps Script ได้
ดำเนินการแปลง |
รองรับด้วยวิธีแก้ปัญหา |
คุณต้องเขียนโค้ดเพื่อแทนที่ VBA API อย่างน้อย 1 รายการด้วย
Apps Script API ที่เทียบเท่า โดยทั่วไป คุณสามารถดำเนินการแปลงได้
คุณสามารถแทนที่ VBA API ที่ทำเครื่องหมายเป็นรองรับด้วย
วิธีแก้ปัญหาด้วยตนเองได้ไม่ว่าจะก่อนหรือหลังจากแปลงไฟล์ เราขอแนะนำให้คุณทำการเปลี่ยนแปลงล่วงหน้า
|
ต้องตรวจสอบเพิ่มเติม |
แปลง API อย่างน้อย 1 รายการไม่ได้ คุณอาจแปลงไฟล์ไม่ได้ ทั้งนี้ขึ้นอยู่กับความสำคัญของ
API นั้นในโค้ด
ผู้ที่เข้าใจโค้ด VBA ต้นฉบับควรเป็นผู้ประเมินขั้นสุดท้าย
หากตัดสินใจแปลงไฟล์ คุณต้องเขียนโค้ดเพื่อแทนที่
VBA API อย่างน้อย 1 รายการด้วย Apps Script คุณสามารถแทนที่
VBA API ที่ทำเครื่องหมายว่าต้องตรวจสอบด้วยตนเองได้ทั้งก่อนและหลัง
แปลงไฟล์ เราขอแนะนำให้คุณทำการเปลี่ยนแปลงล่วงหน้า
|
หลังจากประเมินรายงานความเข้ากันได้แล้ว ให้ดูแปลงมาโคร VBA เป็น Apps
Script
บทความที่เกี่ยวข้อง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eVBA macros with direct Apps Script equivalents are considered compatible and can be automatically converted using the Macro Converter add-on.\u003c/p\u003e\n"],["\u003cp\u003eThe Macro Converter's compatibility report identifies files as "Supported exactly", "Supported with workarounds", or "Needs more investigation", guiding your conversion strategy.\u003c/p\u003e\n"],["\u003cp\u003eFor files needing workarounds or further investigation, manual code adjustments may be necessary before or after conversion using equivalent Apps Script APIs.\u003c/p\u003e\n"],["\u003cp\u003eThe compatibility report provides detailed analysis at the file and API level to help assess conversion feasibility and required actions.\u003c/p\u003e\n"],["\u003cp\u003eAfter reviewing the report, proceed with file conversion, addressing potential issues as outlined in the documentation.\u003c/p\u003e\n"]]],[],null,["# Determine if VBA macros are compatible\n\nAn Excel file with Visual Basic for Applications (VBA) macros is considered\ncompatible if all APIs used in the macros have a direct equivalent in Apps\nScript. If your macros aren't fully compatible, you might be able to apply\nworkarounds or adjust the code to make them work with Apps Script.\n\nUse the Macro Converter's compatibility report to determine if you can\nautomatically convert your files as-is or if you need to make adjustments to\nyour code.\n\nWhen you generate a compatibility report, one of the following statuses is\napplied to each of your files and APIs:\n\n| Status | Definition |\n|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Supported exactly** | These files contain APIs that all have direct equivalents in Apps Script. |\n| **Supported with workarounds** | These files contain at least one API that can be supported with a workaround. |\n| **Needs more investigation** | These files contain at least one API that you need to review to determine how to proceed. For instance, there might not be an equivalent API, or the Macro Converter might not have determined the API in use. |\n\nGenerate a compatibility report\n-------------------------------\n\n1. On your computer, open [Google Drive](https://drive.google.com/drive/my-drive).\n2. On the right side panel, click the Macro Converter add-on . If you don't see the side panel, at the bottom right, click Show side panel chevron_left.\n3. Click **Add files and folders**. The Macro Converter only recognizes Excel files.\n4. Choose the files or folders you want to analyze and click **Select**. Select fewer than 2,000 files at a time.\n5. To change where your compatibility report is saved, click Change destination folder edit, and select the folder you want. Otherwise, it's saved in your MyDrive folder.\n6. Click **Generate report**.\n7. When the analysis completes, click **View report**.\n\nReview the compatibility report\n-------------------------------\n\nUse the details in the compatibility report to help you decide how to proceed\nwith your file conversion. Your report includes the following sections:\n\n- **Summary**: This sheet gives an aggregated analysis of the compatibility of all submitted files and their APIs.\n- **Files - compatibility**: This sheet lists every file submitted to the Macro Converter with the compatibility status and details of each file.\n- **Files - detailed analysis**: This sheet gives more information about the\n APIs within a file and what actions you can take to successfully convert each\n API. First, from the top dropdown menu, select a file. Then, from the bottom\n dropdown menu, select a status.\n\n | **Note:** If multiple files have the same name, next to the file names, use the unique identifiers to tell the difference between them. You can open the files in Drive and look for the unique identifiers in the URLs: `https://drive.google.com/file/d/\u003cfile_identifier\u003e/view`.\n\nYou can also review the report on an API-by-API basis using the sheets called\n**APIs to investigate** and **APIs with workarounds**.\n\nDetermine how to proceed\n------------------------\n\nHere's what we recommend for each status:\n\n| Status | Recommendation |\n|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Supported exactly** | The same logic from your VBA APIs will be replicable in Apps Script. [Proceed with the conversion](/apps-script/guides/macro-converter/convert-files). |\n| **Supported with workarounds** | You need to write code to replace at least one VBA API with the equivalent Apps Script API. In general, you can proceed with the conversion. You can manually replace the VBA APIs marked as *Supported with workarounds* either before or after you convert the file. We recommend that you [make your changes beforehand](/apps-script/guides/macro-converter/convert-files#modify_incompatible_vba_apis). |\n| **Needs more investigation** | At least one API can't be converted. Depending on the importance of that API in your code, you might not be able to convert the file. Someone who understands the original VBA code should do the final evaluation. \u003cbr /\u003e If you decide to convert your file, you need to write code to replace at least one VBA API with Apps Script. You can manually replace the VBA APIs marked as *Needs investigation* either before or after you convert the file. We recommend that you [make your changes beforehand](/apps-script/guides/macro-converter/convert-files#modify_incompatible_vba_apis). |\n\nAfter you assess your compatibility report, see [Convert VBA macros to Apps\nScript](/apps-script/guides/macro-converter/convert-files).\n\nRelated articles\n----------------\n\n- [Macro Converter add-on overview](/apps-script/guides/macro-converter/overview)\n- [Convert VBA macros to Apps Script](/apps-script/guides/macro-converter/convert-files)\n- [Fix errors in your converted code](/apps-script/guides/macro-converter/fix-conversion-errors)\n- [Address common issues](/apps-script/guides/macro-converter/address-conversion-issues)\n- [Watch Macro Converter tutorials](/apps-script/guides/macro-converter/tutorials)\n- [List of compatible VBA APIs](/apps-script/guides/macro-converter/compatible-vba-apis)"]]