Testing for Open Navigation Pane

K

Ken Warthen

Is there some means by which I can programmatically test to see if the
Navigation Pane in an Access 2007 database is hidden? I want to create a
toggle button on the Ribbon that is available to administrators to hide or
show the navigation pane when clicked.
 
P

papazar

Ken Warthen said:
Is there some means by which I can programmatically test to see if the
Navigation Pane in an Access 2007 database is hidden? I want to create a
toggle button on the Ribbon that is available to administrators to hide or
show the navigation pane when clicked.
 
S

Sky

' 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
 
A

Allen Browne

Sky, thanks for posting the API call.

The function uses another called isAcc2007() which people won't have.
Ken, replace the line:
If isAcc2007() Then
with:
If Val(SysCmd(acSysCmdAccessVer)) >= 12# Then
 
K

Ken Warthen

Thanks to both of you for your assistance. I implemented the functions in my
application and it works fine. Thanks again.

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top