ThisWorkBookのイベント一覧です。
どのイベントが発生したかをDebug.Printします。イベントの発生タイミングを測るときに使用してください。
Private Sub Workbook_Activate(): Debug.Print "Workbook_Activate" & Me.Name: End Sub Private Sub Workbook_AddinInstall(): Debug.Print "Workbook_AddinInstall" & Me.Name: End Sub Private Sub Workbook_AddinUninstall(): Debug.Print "Workbook_AddinUninstall" & Me.Name: End Sub Private Sub Workbook_AfterRemoteChange(): Debug.Print "Workbook_AfterRemoteChange" & Me.Name: End Sub Private Sub Workbook_AfterSave(ByVal Success As Boolean): Debug.Print "Workbook_AfterSave" & Me.Name: End Sub Private Sub Workbook_AfterXmlExport(ByVal Map As XmlMap, ByVal Url As String, ByVal Result As XlXmlExportResult): Debug.Print "Workbook_AfterXmlExport" & Me.Name: End Sub Private Sub Workbook_AfterXmlImport(ByVal Map As XmlMap, ByVal IsRefresh As Boolean, ByVal Result As XlXmlImportResult): Debug.Print "Workbook_AfterXmlImport" & Me.Name: End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean): Debug.Print "Workbook_BeforeClose" & Me.Name: End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean): Debug.Print "Workbook_BeforePrint" & Me.Name: End Sub Private Sub Workbook_BeforeRemoteChange(): Debug.Print "Workbook_BeforeRemoteChange" & Me.Name: End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean): Debug.Print "Workbook_BeforeSave" & Me.Name: End Sub Private Sub Workbook_BeforeXmlExport(ByVal Map As XmlMap, ByVal Url As String, Cancel As Boolean): Debug.Print "Workbook_BeforeXmlExport" & Me.Name: End Sub Private Sub Workbook_BeforeXmlImport(ByVal Map As XmlMap, ByVal Url As String, ByVal IsRefresh As Boolean, Cancel As Boolean): Debug.Print "Workbook_BeforeXmlImport" & Me.Name: End Sub Private Sub Workbook_Deactivate(): Debug.Print "Workbook_Deactivate" & Me.Name: End Sub Private Sub Workbook_ModelChange(ByVal Changes As ModelChanges): Debug.Print "Workbook_ModelChange" & Me.Name: End Sub Private Sub Workbook_NewChart(ByVal Ch As Chart): Debug.Print "Workbook_NewChart" & Me.Name: End Sub Private Sub Workbook_NewSheet(ByVal Sh As Object): Debug.Print "Workbook_NewSheet" & Me.Name: End Sub Private Sub Workbook_Open(): Debug.Print "Workbook_Open" & Me.Name: End Sub Private Sub Workbook_PivotTableCloseConnection(ByVal Target As PivotTable): Debug.Print "Workbook_PivotTableCloseConnection" & Me.Name: End Sub Private Sub Workbook_PivotTableOpenConnection(ByVal Target As PivotTable): Debug.Print "Workbook_PivotTableOpenConnection" & Me.Name: End Sub Private Sub Workbook_RowsetComplete(ByVal Description As String, ByVal Sheet As String, ByVal Success As Boolean): Debug.Print "Workbook_RowsetComplete" & Me.Name: End Sub Private Sub Workbook_SheetActivate(ByVal Sh As Object): Debug.Print "Workbook_SheetActivate" & Me.Name: End Sub Private Sub Workbook_SheetBeforeDelete(ByVal Sh As Object): Debug.Print "Workbook_SheetBeforeDelete" & Me.Name: End Sub Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean): Debug.Print "Workbook_SheetBeforeDoubleClick" & Me.Name: End Sub Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean): Debug.Print "Workbook_SheetBeforeRightClick" & Me.Name: End Sub Private Sub Workbook_SheetCalculate(ByVal Sh As Object): Debug.Print "Workbook_SheetCalculate" & Me.Name: End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range): Debug.Print "Workbook_SheetChange" & Me.Name: End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object): Debug.Print "Workbook_SheetDeactivate" & Me.Name: End Sub Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink): Debug.Print "Workbook_SheetFollowHyperlink" & Me.Name: End Sub Private Sub Workbook_SheetLensGalleryRenderComplete(ByVal Sh As Object): Debug.Print "Workbook_SheetLensGalleryRenderComplete" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableAfterValueChange(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal TargetRange As Range): Debug.Print "Workbook_SheetPivotTableAfterValueChange" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableBeforeAllocateChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean): Debug.Print "Workbook_SheetPivotTableBeforeAllocateChanges" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableBeforeCommitChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean): Debug.Print "Workbook_SheetPivotTableBeforeCommitChanges" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableBeforeDiscardChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long): Debug.Print "Workbook_SheetPivotTableBeforeDiscardChanges" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableChangeSync(ByVal Sh As Object, ByVal Target As PivotTable): Debug.Print "Workbook_SheetPivotTableChangeSync" & Me.Name: End Sub Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable): Debug.Print "Workbook_SheetPivotTableUpdate" & Me.Name: End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range): Debug.Print "Workbook_SheetSelectionChange" & Me.Name: End Sub Private Sub Workbook_SheetTableUpdate(ByVal Sh As Object, ByVal Target As TableObject): Debug.Print "Workbook_SheetTableUpdate" & Me.Name: End Sub Private Sub Workbook_Sync(ByVal SyncEventType As Office.MsoSyncEventType): Debug.Print "Workbook_Sync" & Me.Name: End Sub Private Sub Workbook_WindowActivate(ByVal Wn As Window): Debug.Print "Workbook_WindowActivate" & Me.Name: End Sub Private Sub Workbook_WindowDeactivate(ByVal Wn As Window): Debug.Print "Workbook_WindowDeactivate" & Me.Name: End Sub Private Sub Workbook_WindowResize(ByVal Wn As Window): Debug.Print "Workbook_WindowResize" & Me.Name: End Sub
管理者メモ
VBEでイベントをひたすら選択して、作成されたひな形をExcelを使って下記手順で1行に整形。
列 | 式 |
---|---|
A | VBEで作成したひな形を貼り付け |
B | =SUBSTITUTE(A1,”Private Sub “,””) |
C | =LEFT(B1,FIND(“(“,B1)-1) |
D | =”: Debug.Print “””&C1&””” & Me.Name : “ |
E | End Sub |
A,D,Eをコピー→値貼り付け、コピーしてエディタへ
参考:https://www.excel-chunchun.com/entry/vba-event-speed-generate/
コメント