Xác định xem các macro VBA có tương thích hay không
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tệp Excel có macro Visual Basic for Applications (VBA) được coi là tương thích nếu tất cả API được dùng trong macro đều có một API tương đương trực tiếp trong Apps Script. Nếu macro của bạn không hoàn toàn tương thích, bạn có thể áp dụng các giải pháp thay thế hoặc điều chỉnh mã để chúng hoạt động với Apps Script.
Sử dụng báo cáo về khả năng tương thích của Macro Converter để xác định xem bạn có thể tự động chuyển đổi tệp như hiện tại hay cần điều chỉnh mã.
Khi bạn tạo báo cáo về khả năng tương thích, một trong các trạng thái sau sẽ được áp dụng cho từng tệp và API của bạn:
Trạng thái
Định nghĩa
Được hỗ trợ chính xác
Các tệp này chứa những API có các thành phần tương đương trực tiếp trong Apps Script.
Được hỗ trợ bằng giải pháp thay thế
Các tệp này chứa ít nhất một API có thể được hỗ trợ bằng một giải pháp tạm thời.
Cần điều tra thêm
Những tệp này chứa ít nhất một API mà bạn cần xem xét để xác định cách tiến hành. Ví dụ: có thể không có API tương đương hoặc Macro Converter có thể chưa xác định được API đang sử dụng.
Trên bảng điều khiển bên phải, hãy nhấp vào tiện ích bổ sung Macro Converter .
Nếu bạn không thấy bảng điều khiển bên, hãy nhấp vào biểu tượng Hiện bảng điều khiển bên chevron_left ở dưới cùng bên phải.
Nhấp vào Thêm tệp và thư mục. Trình chuyển đổi macro chỉ nhận dạng các tệp Excel.
Chọn tệp hoặc thư mục bạn muốn phân tích rồi nhấp vào Chọn. Chọn ít hơn 2.000 tệp cùng một lúc.
Để thay đổi vị trí lưu báo cáo tương thích, hãy nhấp vào biểu tượng Thay đổi thư mục đích edit rồi chọn thư mục bạn muốn. Nếu không, tệp sẽ được lưu trong thư mục Drive của tôi.
Nhấp vào Tạo báo cáo.
Khi quá trình phân tích hoàn tất, hãy nhấp vào Xem báo cáo.
Xem báo cáo về khả năng tương thích
Hãy sử dụng thông tin chi tiết trong báo cáo về khả năng tương thích để giúp bạn quyết định cách tiến hành chuyển đổi tệp. Báo cáo của bạn bao gồm các phần sau:
Tóm tắt: Trang này cung cấp thông tin phân tích tổng hợp về khả năng tương thích của tất cả các tệp đã gửi và API của các tệp đó.
Tệp – khả năng tương thích: Trang này liệt kê mọi tệp được gửi đến MacroConverter cùng với trạng thái tương thích và thông tin chi tiết của từng tệp.
Tệp – phân tích chi tiết: Trang này cung cấp thêm thông tin về các API trong một tệp và những hành động bạn có thể thực hiện để chuyển đổi thành công từng API. Trước tiên, trong trình đơn thả xuống trên cùng, hãy chọn một tệp. Sau đó, trong trình đơn thả xuống ở dưới cùng, hãy chọn một trạng thái.
Bạn cũng có thể xem xét báo cáo theo từng API bằng cách sử dụng các trang có tên là API cần điều tra và API có giải pháp thay thế.
Xác định cách tiếp tục
Sau đây là những việc bạn nên làm đối với từng trạng thái:
Trạng thái
Nội dung đề xuất
Được hỗ trợ chính xác
Bạn có thể sao chép cùng một logic từ các API VBA trong Apps Script.
Tiến hành chuyển đổi.
Được hỗ trợ bằng giải pháp thay thế
Bạn cần viết mã để thay thế ít nhất một API VBA bằng API Apps Script tương đương. Nhìn chung, bạn có thể tiếp tục quá trình chuyển đổi.
Bạn có thể thay thế theo cách thủ công các API VBA được đánh dấu là Được hỗ trợ bằng giải pháp trước hoặc sau khi chuyển đổi tệp. Bạn nên thực hiện các thay đổi trước đó.
Cần điều tra thêm
Không thể chuyển đổi ít nhất một API. Tuỳ thuộc vào mức độ quan trọng của API đó trong mã, bạn có thể không chuyển đổi được tệp.
Người hiểu rõ mã VBA ban đầu nên thực hiện quy trình đánh giá cuối cùng.
Nếu quyết định chuyển đổi tệp, bạn cần viết mã để thay thế ít nhất một API VBA bằng Apps Script. Bạn có thể thay thế theo cách thủ công các API VBA được đánh dấu là Cần điều tra trước hoặc sau khi chuyển đổi tệp. Bạn nên thực hiện các thay đổi trước đó.
[null,null,["Cập nhật lần gần đây nhất: 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)"]]