' API function to find a child window for an application handle.
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"
(ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As
String, ByVal lpszWindow As String) As Long
' API function that returns 1 if a window handle is visible, 0 if invisible
or the handle is zero
Private Declare Function isWindowVisible Lib "user32" Alias
"IsWindowVisible" (ByVal hwnd As Long) As Long
' Returns True if the navigation window or database window is visible,
otherwise False.
' Example: ?isDbWindowVisible()
Public Function isDbWindowVisible() As Boolean
Dim hwnd As Long
If isAcc2007() Then ' Access 2007 Navigation Pane is a client of Access
itself
hwnd = FindWindowEx(Application.hWndAccessApp, 0,
"NetUINativeHWNDHost", vbNullString)
Else ' Database Browser is a subwindow of MDIClient inside
of Access
hwnd = FindWindowEx(Application.hWndAccessApp, 0, "MDIClient",
vbNullString) ' get Access MDI client Window
hwnd = FindWindowEx(hwnd, 0, "Odb", vbNullString)
' get the Access Database Window
End If
isDbWindowVisible = (isWindowVisible(hwnd) <> 0)
End Function
- Steve