Preserve and Restore Windows Taskbar Auto-Hide with Access VBA
Question details
Preserve the user's Windows taskbar auto-hide setting while temporarily changing it for an Access form.

- Product
- Microsoft Access and Windows taskbar
- Device & OS
- Windows 7 and Windows 10
- Scenario
- An Access form needs a temporary taskbar auto-hide setting and should restore the user's original preference when it closes.
- Observed behavior
- The original taskbar state is saved before the form changes it and restored when the form closes.
Open the Access database and identify the form that needs the temporary taskbar setting. The example uses VBA7 declarations, as supported by Access 2013, and assumes only one form manages this taskbar override at a time.
Save and restore the taskbar state with Access VBA
Use the Windows shell API to disable auto-hide while a form is open, then restore the saved state when the form closes.
ABM_GETSTATE retrieves the current taskbar state. The example changes only the auto-hide flag and uses ABM_SETSTATE to restore the saved state if a change was needed.
Restoration depends on the form closing normally. A crash or forced termination can prevent the close event from running, so test the behavior before relying on it.
In Access, press Alt+F11, choose Insert > Module, and paste this code: Option Explicit Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type APPBARDATA cbSize As Long hWnd As LongPtr uCallbackMessage As Long uEdge As Long rc As RECT lParam As LongPtr End Type Private Declare PtrSafe Function SHAppBarMessage Lib "shell32.dll" _ (ByVal dwMessage As Long, ByRef pData As APPBARDATA) As LongPtr Private Const ABM_GETSTATE As Long = &H4 Private Const ABM_SETSTATE As Long = &HA Private Const ABS_AUTOHIDE As Long = &H1 Private savedTaskbarState As Long Private taskbarChanged As Boolean Public Sub DisableTaskbarAutoHide() Dim data As APPBARDATA Dim currentState As Long If taskbarChanged Then Exit Sub data.cbSize = LenB(data) currentState = CLng(SHAppBarMessage(ABM_GETSTATE, data)) savedTaskbarState = currentState If (currentState And ABS_AUTOHIDE) <> 0 Then data.lParam = currentState And Not ABS_AUTOHIDE taskbarChanged = True Call SHAppBarMessage(ABM_SETSTATE, data) End If End Sub Public Sub RestoreTaskbarState() Dim data As APPBARDATA If Not taskbarChanged Then Exit Sub data.cbSize = LenB(data) data.lParam = savedTaskbarState Call SHAppBarMessage(ABM_SETSTATE, data) taskbarChanged = False End Sub
Open the form in Design View, open its code module, and add these event procedures: Private Sub Form_Load() DisableTaskbarAutoHide End Sub Private Sub Form_Close() RestoreTaskbarState End Sub If either event procedure already exists, add the corresponding call to it instead of creating a duplicate.
Use Windows taskbar settings to test with auto-hide enabled and disabled. Open and close the Access form each time, and confirm that the original setting is restored.

Use WPS Office for everyday document and spreadsheet work
WPS Office is a free, lightweight alternative for common Office work, with a familiar interface and support for Microsoft Office formats to make switching easier. It does not replace Microsoft Access or run this Access VBA taskbar solution.

Frequently Asked Questions
How does Access VBA detect the current taskbar auto-hide setting?
Call SHAppBarMessage with ABM_GETSTATE and check whether the returned state includes the ABS_AUTOHIDE flag.
Why save the whole taskbar state instead of just the auto-hide flag?
Saving the returned state allows ABM_SETSTATE to restore the original state rather than setting auto-hide to an assumed default.
Will the taskbar setting be restored if Access crashes?
Not necessarily. A crash or forced termination can prevent the form's Close event from running. If needed, restore auto-hide manually through Windows taskbar settings.
Does the code change the taskbar if auto-hide is already off?
No. DisableTaskbarAutoHide checks the ABS_AUTOHIDE flag first and calls ABM_SETSTATE only when the flag is enabled.
Can WPS Office run this Access VBA solution?
No. This solution requires Microsoft Access VBA and the Windows shell API. WPS Office can be used separately for compatible documents, spreadsheets, and presentations.




