Hello Excel Professionals, this is my first post here.
I found on the internet a VBA code that allows me to set the taskbar Auto Hide on. It works like a charm, perfect. The problem is that to set it back to OFF it does not work. I mean I need the taskbar autohide to set to OFF when I call the Sub UnhideTaskbar below. But it does not work at all. There are some other codes on the net that only hides the taskbar, but It doesn't work because it won't allow full screen to fill it'a place on the screen. So I must use the Auto Hide property.
Again, The Goal is to Set taskbar AutoHide OFF. How can I do it?
Thanks !
CODE:
Option Explicit
' d_taskbar, turns the system taskbar on or off :: FullScreen Excel AddIn
' SHAppBarMessage
Private Declare PtrSafe Function _
SHAppBarMessage Lib "shell32.dll" _
(ByVal dwMessage As Long, _
ByRef pData As APPBARDATA) As Long
' local const
Public Const ABS_AUTOHIDE As Long = &H1
Public Const ABM_GETTASKBARPOS As Long = &H5
Public Const ABM_GETSTATE As Long = &H4
Public Const ABM_SETSTATE As Long = &HA
Public Const ABM_SETAUTOHIDEBAR As Long = &H8
Public Const ABS_ALWAYSONTOP = &H2
' local type
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 Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
' local vars
Dim abd As APPBARDATA
Dim abd_retval, _
abd_setval As Long
' AutoHideTaskBar :: sets the appdardata, lParam struct to autohide the system taskbar
Public Sub HideTaskbar()
On Error GoTo TaskbarErrorHandler
Application.EnableCancelKey = xlErrorHandler
abd_retval = _
SHAppBarMessage(ABM_GETSTATE, abd)
abd.lParam = _
abd_retval Or ABS_AUTOHIDE
abd_setval = _
SHAppBarMessage(ABM_SETSTATE, abd)
Exit Sub
TaskbarErrorHandler:
On Error Resume Next
End Sub
' /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' RestoreTaskBar :: restores the autohide system taskbar to a normal state
Public Sub UnhideTaskbar()
On Error GoTo TaskbarErrorHandler
Application.EnableCancelKey = xlErrorHandler
abd_retval = _
SHAppBarMessage(ABM_GETSTATE, abd)
abd.lParam = _
ABS_ALWAYSONTOP
abd_setval = _
SHAppBarMessage(ABM_SETSTATE, abd)
Exit Sub
TaskbarErrorHandler:
On Error Resume Next
End Sub
Bookmarks