Results 1 to 18 of 18

[SOLVED] VBA Code to set Windows Taskbar auto hide to OFF

Threaded View

  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    brazil
    MS-Off Ver
    Excel 2010
    Posts
    14

    [SOLVED] VBA Code to set Windows Taskbar auto hide to OFF

    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
    Last edited by claudiocustodio; 09-01-2021 at 12:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto Close code preventing access to taskbar
    By JRC1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-03-2017, 11:12 AM
  2. [SOLVED] Windows in Taskbar
    By faulknerp in forum Excel General
    Replies: 1
    Last Post: 06-22-2006, 09:50 PM
  3. [SOLVED] Windows in Taskbar
    By faulknerp in forum Excel General
    Replies: 2
    Last Post: 12-16-2005, 11:00 AM
  4. [SOLVED] Windows in taskbar
    By in forum Excel General
    Replies: 2
    Last Post: 03-08-2005, 01:06 PM
  5. why do windows in taskbar go away
    By j-dawg in forum Excel General
    Replies: 1
    Last Post: 02-16-2005, 01:16 PM
  6. Windows in Taskbar
    By jma in forum Excel General
    Replies: 0
    Last Post: 01-17-2005, 10:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1