Public WithEvents pDataWindowEvents As TableWindow Public pTableWindow As ITableWindow3 Public Sub TableWindowTest() ' Create a TableWindow Object and add Application object to it Set pTableWindow = New TableWindow Set pTableWindow.Application = Application ' Get a handle on the open tables in TableWindow as a set object Dim s As ISet pTableWindow.FindOpenTableWindows s Debug.Print "number of tables open in TableWindow: " & s.Count s.Reset If s.Count = 0 Then Debug.Print "Window not open!" Else ' Get first table from set object Dim pTW As ITableWindow Set pTW = s.Next ' Wire up event listener to this specific table Set pDataWindowEvents = pTW ' Get the Table object Dim pTable As ITable Set pTable = pTW.Table ' Report some info in debug Dim pDataset As IDataset Set pDataset = pTable Debug.Print "Returned Table: " & pDataset.Name Debug.Print "Number of rows:" & pTable.RowCount(Nothing) End If End Sub Private Sub pDataWindowEvents_HideWindow(ByVal window As esriArcMapUI.IDataWindow) MsgBox "goodbye!" End Sub Private Sub pDataWindowEvents_ShowWindow(ByVal window As esriArcMapUI.IDataWindow) MsgBox "hello!" End Sub