OFF97: How to Programmatically Hide and Unhide the Windows Taskbar

Article translations Article translations
Article ID: 186119 - View products that this article applies to.
This article was previously published under Q186119
This article has been archived. It is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.

For a Microsoft Office XP version of this article, see 290150.
For a Microsoft Office 2000 version of this article, see 202099.
Expand all | Collapse all

Summary

By using API calls in Visual Basic for Applications, you can programmatically hide the Microsoft Windows 95 or later, or Microsoft Windows NT 4.0 taskbar. This article shows you how to create the two functions that you need to hide and unhide the taskbar.

More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To create the functions and to see how they work, follow these steps:
  1. Press ALT+F11 to start the Visual Basic Editor (or in Microsoft Access, open a database.)
  2. Type the following code in a new module:
          Option Compare Database  ' In Microsoft Access only.
          Option Explicit
    
          Dim handleW1 As Long
    
          Private Declare Function FindWindowA Lib "user32" _
          (ByVal lpClassName As String, _
          ByVal lpWindowName As String) As Long
    
          Private Declare Function SetWindowPos Lib "user32" _
          (ByVal handleW1 As Long, _
          ByVal handleW1InsertWhere As Long, ByVal w As Long, _
          ByVal x As Long, ByVal y As Long, ByVal z As Long, _
          ByVal wFlags As Long) As Long
    
          Const TOGGLE_HIDEWINDOW = &H80
          Const TOGGLE_UNHIDEWINDOW = &H40
    
          Function HideTaskbar()
             handleW1 = FindWindowA("Shell_traywnd", "")
             Call SetWindowPos(handleW1, 0, 0, 0, _
             0, 0, TOGGLE_HIDEWINDOW)
          End Function
    
          Function UnhideTaskbar()
             Call SetWindowPos(handleW1, 0, 0, 0, _
             0, 0, TOGGLE_UNHIDEWINDOW)
          End Function
    					
  3. In Excel or Word, click Immediate Window on the View menu, type the following command, and then press ENTER:
    ?HideTaskBar()
    In Microsoft Access, type the command above in the Debug Window, and then press ENTER.

    Note that the taskbar is no longer visible.
  4. To restore the taskbar in Excel or Word, type the following command in the Immediate Window, and then press ENTER:
    ?UnHideTaskBar()
    In Microsoft Access, type the command above in the Debug Window, and then press ENTER.

    Note that the taskbar is now visible.

References

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
163435 VBA: Programming Resources for Visual Basic for Applications

Properties

Article ID: 186119 - Last Review: October 26, 2013 - Revision: 5.0
Applies to
  • Microsoft Access 97 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • Microsoft Word 97 Standard Edition
Keywords: 
kbnosurvey kbarchive kbhowto KB186119

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com