Solved

VBA - Is Access 2013 Navigation Pane Visible

Posted on 2014-04-17
9
2,448 Views
Last Modified: 2014-04-17
I use the following code to hid the navigation pane:
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide

I use the following code to show the navigation pane:
DoCmd.SelectObject acTable, , True

What code do I use for:
Public Function IsNavigationPaneVisible() as boolean
dim fReturn as boolean
fReturn=?????
IsNavigationPaneVisible=fReturn
Exit Function
0
Comment
Question by:rmk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 40006641
Not sure if this will work in A2013 or not.  Give it a shot:

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

Private Declare Function isWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As Long) As Long

Public Function isDbWindowVisible() As Boolean
Dim hWindow As Long
If Int(SysCmd(acSysCmdAccessVer)) >= 12 Then
hWindow = FindWindowEx(Application.hWndAccessApp, 0, "NetUINativeHWNDHost", vbNullString)
hWindow = FindWindowEx(hWindow, 0, "NetUIHWND", vbNullString)
Else
hWindow = FindWindowEx(Application.hWndAccessApp, 0, "MDIClient", vbNullString)
hWindow = FindWindowEx(hWindow, 0, "Odb", vbNullString)
End If
isDbWindowVisible = (isWindowVisible(hWindow) <> 0)
End Function
0
 

Author Closing Comment

by:rmk
ID: 40006719
That's exactly what I needed. THANKS !
0
 

Author Comment

by:rmk
ID: 40006748
Actually, I thing your code needs a couple of minor changes for VBA7, i.e. the Declare statement needs PtrSafe and the handles should be delcared as LongPtr instead of Long

Declare PtrSafe Function IsWindowVisible Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As LongPtr) As Long

Dim hWindow As LongPtr
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:rmk
ID: 40006917
It works fine when I open my application with the shift key depressed and then manually open the startup form called frmMain. I can use F11 to toggle the navigation pane and the code always returns the correct true or false value.

However the code always returns true when I open my application without the shift key depressed. There is no autoexec macro and the DisplayForm drop down list is set to frmMain. The only psuedo startup code is:

Public grbnForm                     As IRibbonUI
Public grbnBackStage                As IRibbonUI

Public Sub FormRibbonOnLoad(ribbon As IRibbonUI)
    Set grbnForm = ribbon
End Sub

Public Sub BackStageRibbonOnLoad(ribbon As IRibbonUI)
    Set grbnBackStage = ribbon
End Sub

Any ideas ?????
0
 
LVL 57
ID: 40006944
<<Actually, I thing your code needs a couple of minor changes for VBA7, i.e. the Declare statement needs PtrSafe and the handles should be delcared as LongPtr instead of Long>>

 That's only if your running 64 bit instead of 32 bit Office.

<<Any ideas ????? >>

 In frmMain, try an explicit hide of the nav pane, and then see if it starts returning the correct value.

Jim.
0
 

Author Comment

by:rmk
ID: 40007077
The explicit hide did not work.

Since 32 bit Office is running on 64 bit Windows, I thought all window handles were 64 bit and therefore had to be declared with PtrSafe as LongPtr. At least that's what it implies in Win32API_PtrSafe.txt that I downloaded as part of Office 2010 Developer Resources which has the following preambel
'
'             Win32API_PtrSafe.TXT -- Declare statements for
'         Visual Basic for Applications and Microsoft Office 2010
'
'              Copyright (C) 2010 Microsoft Corporation.
'                         All rights reserved.
'
'
' This file contains Declare statements for many functions in the
' Microsoft Windows API for use with Visual Basic for Applications (VBA)
' and Microsoft Office 2010 on 32-bit (x86) and 64-bit (x64) platforms.
'
' The declare statements in this file are not compatible with VB6 or
' previous versions of Microsoft Office. Refer to the Microsoft Windows
' Programmer's Reference for further information on the use of Windows APIs.
'
' You may use, modify, reproduce, and distribute this file (and/or any
' modified version), for use with any of the Microsoft technologies
' described above.  THIS FILE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY
' KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF
' FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
0
 
LVL 57
ID: 40007121
<<Since 32 bit Office is running on 64 bit Windows, I thought all window handles were 64 bit and therefore had to be declared with PtrSafe as LongPtr. At least that's what it implies in Win32API_PtrSafe.txt that I downloaded as part of Office 2010 Developer Resources which has the following preambel>>

 No, it's optional when making calls from 32 bit.  It's only required when your using 64 bit office. Read the section "Application Programming Interface Compatibility"  here:

http://msdn.microsoft.com/en-us/library/ee691831%28v=office.14%29.aspx

and note that:

"Note that the PtrSafe attribute is optional on the 32-bit version of Office 2010. This enables existing Declare statements to work as they always have. "

 as for why it's not working, I don't know.  I'd have to dig into it and don't have the time at the moment.

   I picked up the code somewhere just out of interest on the chance that I might use it some day.  Never tried it.

Jim.
0
 

Author Comment

by:rmk
ID: 40007211
I read your link carefully this time, and as usual you are correct.
BTW, I unchecked the  the Display Navigation Pane check box in Current Database Options and explicitly hide the navigation window in frmMain. Now the IsVisible function works properly.
You continue to be one of most valued resources - thank you for your superb support!
0
 
LVL 57
ID: 40007730
Glad to hear your squared away...

Jim.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question