+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: toggle taskbar

  1. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello SuitedAces,

    The code looks fine. So, I am going to ask an obvious question, did you copy the macro into a Standard VBA Module?

    Sincerely,
    Leith Ross

  2. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello SuitedAces,

    I hope this reply posts. The following code conatins two macros, one to hide, and the other to show the Task Bar. These actually set or clear the visible property through the API. A word of caution, hiding the Task Bar will lock out the Launch Bar which means you can't switch tasks by clicking on the icon. This why the Task Bar as an "Auto Hide" feature. This feature really minimizes the Task Bar (to a few pixels in height) and doesn't lock out the Launch Bar.
    'Written: October 30, 2007
    'Author: Leith Ross
    'Summary: Hide or Show the System Tray by setting or clearing the Visible bit.
    
    Private Const GWL_STYLE = (-16)
    Private Const WS_VISIBLE As Long = &H10000000
    
      Private Declare Function GetWindowLong _
        Lib "user32.dll" _
          Alias "GetWindowLongA" _
            (ByVal hWnd As Long, _
             ByVal nIndex As Long) As Long
    
      Private Declare Function SetWindowLong _
        Lib "user32.dll" _
          Alias "SetWindowLongA" _
            (ByVal hWnd As Long, _
             ByVal nIndex As Long, _
             ByVal dwNewLong As Long) As Long
    
      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
    
    Public Function IsTaskbarVisible() As Boolean
    
      Dim hWnd As Long
      Dim Ret As Long
    
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        Ret = GetWindowLong(hWnd, GWL_STYLE)
      
        If Ret And WS_VISIBLE Then IsTaskbarVisible = True
    
    End Function
    
    Public Sub HideTaskBar()
    
      Dim hWnd As Long
      Dim Ret As Long
      Dim WinStyle As Long
      
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        WinStyle = GetWindowLong(hWnd, GWL_STYLE)
        
          WinStyle = WinStyle And (Not WS_VISIBLE)
          Ret = SetWindowLong(hWnd, GWL_STYLE, WinStyle)
          
       X = Hex(WinStyle)
    
    End Sub
         
    Public Sub ShowTaskBar()
    
      Dim hWnd As Long
      Dim Ret As Long
      Dim WinStyle As Long
      
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        WinStyle = GetWindowLong(hWnd, GWL_STYLE)
        
          WinStyle = WinStyle Or WS_VISIBLE
          Ret = SetWindowLong(hWnd, GWL_STYLE, WinStyle)
          
       X = Hex(WinStyle)
       
    End Sub
    Sincerely,
    Leith Ross

  3. #18
    Valued Forum Contributor
    Join Date
    06-27-2006
    Posts
    230
    Quote Originally Posted by Leith Ross
    Hello SuitedAces,

    The code looks fine. So, I am going to ask an obvious question, did you copy the macro into a Standard VBA Module?

    Sincerely,
    Leith Ross
    Yes Leith I had it in a standard module

  4. #19
    Valued Forum Contributor
    Join Date
    06-27-2006
    Posts
    230
    Quote Originally Posted by Leith Ross
    Hello SuitedAces,

    I hope this reply posts. The following code conatins two macros, one to hide, and the other to show the Task Bar. These actually set or clear the visible property through the API. A word of caution, hiding the Task Bar will lock out the Launch Bar which means you can't switch tasks by clicking on the icon. This why the Task Bar as an "Auto Hide" feature. This feature really minimizes the Task Bar (to a few pixels in height) and doesn't lock out the Launch Bar.
    'Written: October 30, 2007
    'Author: Leith Ross
    'Summary: Hide or Show the System Tray by setting or clearing the Visible bit.
    
    Private Const GWL_STYLE = (-16)
    Private Const WS_VISIBLE As Long = &H10000000
    
      Private Declare Function GetWindowLong _
        Lib "user32.dll" _
          Alias "GetWindowLongA" _
            (ByVal hWnd As Long, _
             ByVal nIndex As Long) As Long
    
      Private Declare Function SetWindowLong _
        Lib "user32.dll" _
          Alias "SetWindowLongA" _
            (ByVal hWnd As Long, _
             ByVal nIndex As Long, _
             ByVal dwNewLong As Long) As Long
    
      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
    
    Public Function IsTaskbarVisible() As Boolean
    
      Dim hWnd As Long
      Dim Ret As Long
    
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        Ret = GetWindowLong(hWnd, GWL_STYLE)
      
        If Ret And WS_VISIBLE Then IsTaskbarVisible = True
    
    End Function
    
    Public Sub HideTaskBar()
    
      Dim hWnd As Long
      Dim Ret As Long
      Dim WinStyle As Long
      
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        WinStyle = GetWindowLong(hWnd, GWL_STYLE)
        
          WinStyle = WinStyle And (Not WS_VISIBLE)
          Ret = SetWindowLong(hWnd, GWL_STYLE, WinStyle)
          
       X = Hex(WinStyle)
    
    End Sub
         
    Public Sub ShowTaskBar()
    
      Dim hWnd As Long
      Dim Ret As Long
      Dim WinStyle As Long
      
        hWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
        WinStyle = GetWindowLong(hWnd, GWL_STYLE)
        
          WinStyle = WinStyle Or WS_VISIBLE
          Ret = SetWindowLong(hWnd, GWL_STYLE, WinStyle)
          
       X = Hex(WinStyle)
       
    End Sub
    Sincerely,
    Leith Ross
    Thank you Leith .

    But I don't truely meet my objective here with being able to toggle the taskbar by way of returning a value that indicates whether the taskbar is hidden or displayed.

  5. #20
    Registered User
    Join Date
    10-19-2010
    Location
    netherlands
    MS-Off Ver
    Excel 2007, 2010 (Win 7 x64)
    Posts
    10

    Re: toggle taskbar

    When I use one of the previous codes in excel 2007, it makes the task bar invisible but it will show the start button.
    is the code for 2007 different? and does anybody know how to temporarily fully remove the task bar with VBA?

  6. #21
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: toggle taskbar

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0