I discovered the following code (courtesy to Tom Urtis MVP) to Autohide the Taskbar but what I would like to do is store the state of Autohide in the Workbook_Open event - set it to autohide the taskbar - then restore it to the stored state in the Workbook_Close event.
I tried debugging the code myself but my knowledge of Windows API code is somewhat limited and hence had no joy but in this process I also uncovered a couple of problems...
(i) the code strangely sometimes returns focus to the VBE editor so I got round this by putting the following line in...
(ii) but then even with Application.ScreenUpdating set to false, the API code ignores this so I am assuming there is nothing that can be done about some screen activity/flickering - which is fine really in the swing of things.
But my main question remains - how can I get the current state of Autohide - store it - and restore it later ?
Any assistance gratefully received
Cheers
Jabba
I tried debugging the code myself but my knowledge of Windows API code is somewhat limited and hence had no joy but in this process I also uncovered a couple of problems...
(i) the code strangely sometimes returns focus to the VBE editor so I got round this by putting the following line in...
Code:
Application.VBE.MainWindow.Visible = False
(ii) but then even with Application.ScreenUpdating set to false, the API code ignores this so I am assuming there is nothing that can be done about some screen activity/flickering - which is fine really in the swing of things.
But my main question remains - how can I get the current state of Autohide - store it - and restore it later ?
Any assistance gratefully received
Cheers
Jabba
Code:
Public Declare Function SHAppBarMessage Lib "shell32" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Public Const ABM_GETSTATE = &H4
Public Const ABM_SETSTATE = &HA
Public Const ABS_AUTOHIDE = &H1
Public Const ABS_ALWAYSONTOP = &H2
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
Sub TaskbarAutohideOff()
' Code courtesy of Tom Urtis in San Fransisco and patched by sbendbuckeye (Gary) circa. 2007.
Dim ABD As APPBARDATA
ABD.cbSize = Len(ABD)
SHAppBarMessage ABM_GETSTATE, ABD
ABD.lParam = ABS_ALWAYSONTOP
SHAppBarMessage ABM_SETSTATE, ABD
Application.VBE.MainWindow.Visible = False
End Sub
Sub TaskbarAutohideOn()
' Code courtesy of Tom Urtis in San Fransisco circa. 2007.
Dim ABD As APPBARDATA
ABD.cbSize = Len(ABD)
SHAppBarMessage ABM_GETSTATE, ABD
ABD.lParam = ABS_AUTOHIDE Or ABS_ALWAYSONTOP
SHAppBarMessage ABM_SETSTATE, ABD
Application.VBE.MainWindow.Visible = False
End Sub