특정 통합 문서를 닫을 때마다 Excel에서 자동으로 매크로를 실행하도록 할 수 있습니다. 예를 들어 통합 문서가 닫힐 때 사용자에게 하루의 데이터를 다른 파일에 저장하는 것과 같은 작업을 수행할지 묻는 매크로를 실행할 수 있습니다.

통합 문서가 닫힐 때 매크로를 자동으로 실행하려면 매크로 이름을 Auto_Close ()로 지정하기 만하면됩니다. 따라서 다음 예제 매크로는 포함 된 통합 문서를 닫을 때마다 자동으로 실행됩니다.

Sub Auto_Close()

Dim intStatusState As Integer

intStatusState = Application.DisplayStatusBar     Application.DisplayStatusBar = True     Application.StatusBar = "Examining transactions."

DetermineTransactions     Application.StatusBar = "Posting transactions."

PostTransactions     Application.StatusBar = False     Application.DisplayStatusBar = intStatusState End Sub

_ 참고 : _

이 페이지 (또는 ExcelTips 사이트의 다른 페이지)에 설명 된 매크로를 사용하는 방법을 알고 싶다면 유용한 정보가 포함 된 특별 페이지를 준비했습니다.

link : / excelribbon-ExcelTipsMacros [새 브라우저 탭에서 특별 페이지를 열려면 여기를 클릭하세요].

_ExcelTips_는 비용 효율적인 Microsoft Excel 교육을위한 소스입니다.

이 팁 (10372)은 Microsoft Excel 2007, 2010 및 2013에 적용됩니다. 여기에서 Excel의 이전 메뉴 인터페이스에 대한이 팁의 버전을 찾을 수 있습니다.

link : / excel-Running_a_Macro_when_a_Workbook_is_Closed [통합 문서가 닫힐 때 매크로 실행].