일반적인 문제 해결
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Macro Converter를 사용하여 VBA 코드를 Apps Script로 변환할 때 발생할 수 있는 일반적인 문제는 아래에 나열되어 있습니다.
인쇄
파일을 인쇄하는 VBA API는 자동으로 Apps Script로 변환되지만 원래 VBA API와 다르게 동작할 수 있습니다. 다음은 두 가지 예시입니다.
VBA API | Apps Script의 동작 |
---|
PrintOut | Apps Script로 변환되지만 Apps Script API는 프린터가 아닌 파일에 인쇄됩니다. PDF 파일을 수동으로 인쇄할 수 있습니다. |
PrintToFile | Apps Script로 변환합니다. PDF 파일이 내 드라이브 폴더에 저장됩니다. |
전환되지 않은 항목
다음 기능은 매크로 변환기로 변환되지 않으므로 수동으로 변환해야 합니다.
트리거
두 가지 유형의 트리거(단축키 및 일부 이벤트 기반 트리거)는 매크로 변환기로 변환되지 않습니다. 대부분의 경우 이러한 트리거를 수동으로 만들 수 있습니다.
단축키
단축키를 추가하려면 함수를 매크로로 가져오기 단계를 따르세요.
이벤트 기반 트리거
BeforeClose
또는 BeforeSave
과 같은 VBA 코드의 일부 이벤트는 Apps Script에 상응하는 이벤트가 없지만 해결 방법을 만들 수 있습니다.
BeforeClose
와 같은 이벤트의 경우 스프레드시트를 닫기 전에 실행해야 하는 작업을 클릭하여 실행할 수 있는 맞춤 메뉴나 버튼을 만들 수 있습니다.
Google Sheets는 각 수정사항을 자동 저장하므로 BeforeSave
와 같은 이벤트에 대한 해결 방법은 불가능합니다.
VBA에서 UserForm은 애플리케이션의 사용자 인터페이스 (UI)에 있는 창 또는 대화상자입니다. 매크로 변환기는 UserForm을 변환하지 않습니다. Apps Script에서 수동으로 만들 수 있습니다.
- 컴퓨터에서 변환된 파일을 Google Sheets로 엽니다.
- 상단에서 확장 프로그램 >
** Apps Script**를 클릭합니다.
- 편집기 왼쪽의 '파일' 옆에 있는 파일 추가 add
> HTML을 클릭합니다. HTML 파일에 원래 VBA UserForm과 동일한 이름을 지정하는 것이 좋습니다.
- 양식에 표시할 필드와 정보를 추가합니다. W3school.com에서 HTML 양식에 대해 자세히 알아보세요.
- 왼쪽에서 변환된 코드가 있는 Apps Script 파일 (GS 파일)을 클릭합니다.
- 코드에
onOpen()
트리거가 이미 있는 경우 아래 코드로 업데이트합니다. 코드에 onOpen()
트리거가 없으면 아래 코드를 추가합니다.
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('User Form')
.addItem('Show Form', 'showForm')
.addToUi();
}
function showForm() {
var html = HtmlService.createHtmlOutputFromFile('userform_module_name')
.setWidth(100)
.setTitle('Sign-up for Email Updates');
SpreadsheetApp.getUi().showSidebar(html);
}
userform_module_name
을 추가한 HTML 파일의 이름으로 바꿉니다.
- 상단에서 프로젝트 저장 save을 클릭합니다.
- Google Sheets로 전환하고 페이지를 새로고침합니다.
- Google 시트 상단에서 사용자 양식 > 양식 표시를 클릭합니다.
이름이 지정된 범위
Excel에서 이름이 지정된 범위는 단일 셀 또는 셀 범위에 지정된 이름입니다.
Excel 파일을 Google Sheets로 변환할 때 지원되지 않는 일부 유형의 이름이 지정된 범위는 변환되지 않습니다. 다음은 두 가지 예시입니다.
지원되지 않는 이름이 지정된 범위 | 설명 |
---|
테이블 | Google Sheets에서 지원되지 않지만 해결 방법이 있습니다.
Sheets에서 이 명명된 범위를 다시 만들려면 테이블 범위의 A1 표기법을 가리키는 명명된 범위를 추가하세요. 변환된 코드가 인식할 수 있도록 VBA 코드에서 원래 이름이 지정된 범위와 동일한 이름을 사용합니다.
|
범위 목록 | Google Sheets에서는 지원되지 않습니다. 해결 방법이 없습니다. |
관련 도움말
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eWhen converting VBA to Apps Script, printing functions behave differently; \u003ccode\u003ePrintOut\u003c/code\u003e prints to a file instead of directly to a printer, while \u003ccode\u003ePrintToFile\u003c/code\u003e saves the PDF to your MyDrive.\u003c/p\u003e\n"],["\u003cp\u003eThe Macro Converter does not handle certain VBA features, including some triggers, UserForms, and unsupported named ranges, requiring manual conversion.\u003c/p\u003e\n"],["\u003cp\u003eKeyboard shortcuts and some event-based triggers (like \u003ccode\u003eBeforeClose\u003c/code\u003e or \u003ccode\u003eBeforeSave\u003c/code\u003e) from VBA require manual configuration or workarounds in Apps Script due to functional differences.\u003c/p\u003e\n"],["\u003cp\u003eUserForms need to be recreated in Apps Script using HTML, and integrated into the spreadsheet through custom menus or sidebars.\u003c/p\u003e\n"],["\u003cp\u003eWhile most named ranges are converted, tables and lists of ranges require manual adjustments or are unsupported, necessitating alternative approaches in Google Sheets.\u003c/p\u003e\n"]]],[],null,["# Address common issues\n\nCommon issues you might run into when you convert your VBA code to Apps Script\nwith the Macro Converter are listed below.\n\nPrinting\n--------\n\nVBA APIs that print files are automatically converted to Apps Script, but might\nbehave differently than the original VBA API. Below are two examples:\n\n| VBA API | Behavior in Apps Script |\n|---------------|------------------------------------------------------------------------------------------------------------------------------|\n| `PrintOut` | Converts to Apps Script, but the Apps Script API prints to a file instead of a printer. You can manually print the PDF file. |\n| `PrintToFile` | Converts to Apps Script. The PDF file is saved in your MyDrive folder. |\n\nUnconverted items\n-----------------\n\nThe following features aren't converted by the Macro Converter and need to be\nconverted manually:\n\n- Some types of [Triggers](#triggers)\n- [Userforms](#userforms)\n- Unsupported types of [Named ranges](#named_ranges)\n\n### Triggers\n\nTwo types of triggers, keyboard shortcuts and some event-based triggers, aren't\nconverted by the Macro Converter. In many cases, you can create these triggers\nmanually.\n\n#### Keyboard shortcuts\n\nTo add keyboard shortcuts, follow the steps to [import functions as\nmacros](https://developers.google.com/apps-script/guides/sheets/macros#importing_functions_as_macros).\n\n#### Event-based triggers\n\nSome events from VBA code, like `BeforeClose` or `BeforeSave`, don't have\nequivalents in Apps Script, but you might be able to create a workaround.\n\nFor events like `BeforeClose`, you can create a custom menu or button to click\nto perform the action that needs to take place before you close the spreadsheet.\n\nSince Google Sheets auto-saves each edit, workarounds for events like\n`BeforeSave` aren't feasible.\n\n### Userforms\n\nIn VBA, a [*UserForm*](https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/userform-object) is a window or dialog box in an application's user\ninterface (UI). The Macro Converter doesn't convert UserForms. You can manually\ncreate them in Apps Script.\n\n#### Create a user form dialogue\n\n1. On your computer, open the converted file in [Google Sheets](http://sheets.google.com).\n2. At the top, click **Extensions** \\\u003e \\*\\* Apps Script\\*\\*.\n3. At the left of the editor next to \"Files,\" click Add a file add **\\\u003e HTML**. We recommend that you give the HTML file the same name as your original VBA UserForm.\n4. Add the fields and information you want to appear in your form. Learn more about HTML forms at [W3school.com](https://www.w3schools.com/html/html_forms.asp).\n5. At the left, click the Apps Script file (GS file) that has your converted code.\n6. If you already have an `onOpen()` trigger in your code, update it with the code below. If you don't have the `onOpen()` trigger in your code, add the code below. \n\n ```gdscript\n function onOpen() {\n SpreadsheetApp.getUi()\n .createMenu('User Form')\n .addItem('Show Form', 'showForm')\n .addToUi();\n }\n function showForm() {\n var html = HtmlService.createHtmlOutputFromFile('userform_module_name')\n .setWidth(100)\n .setTitle('Sign-up for Email Updates');\n SpreadsheetApp.getUi().showSidebar(html);\n }\n \n ```\n7. Replace `userform_module_name` with the name of the HTML file you added.\n8. At the top, click Save project save.\n9. Switch to the Google Sheet and reload the page.\n10. At the top of the Google Sheet, click **User Form** \\\u003e **Show Form**.\n\n### Named ranges\n\nIn Excel, named ranges are names given to a single cell or range of cells.\n\nWhen you convert your Excel file to Google Sheets, some types of named ranges\nwon't be converted because they're not supported. Below are two examples:\n\n| Unsupported named ranges | Description |\n|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Tables | Not supported in Google Sheets, but has a workaround. \u003cbr /\u003e To recreate this named range in Sheets, add a named range that points to the A1 notation of the table range. Use the same name as the original named range in your VBA code so that the converted code recognizes it. |\n| List of ranges | Not supported in Google Sheets. There isn't a workaround. |\n\nRelated articles\n----------------\n\n- [Macro Converter add-on overview](/apps-script/guides/macro-converter/overview)\n- [Determine if VBA macros are compatible](/apps-script/guides/macro-converter/compatibility-report)\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- [Watch Macro Converter tutorials](/apps-script/guides/macro-converter/tutorials)\n- [List of compatible VBA APIs](/apps-script/guides/macro-converter/compatible-vba-apis)"]]