Microsoft KB Archive/194884

= OL98: How to Programmatically Change Outlook's User Interface =

Article ID: 194884

Article Last Modified on 2/27/2004

-

APPLIES TO


 * Microsoft Outlook 98 Standard Edition

-



This article was previously published under Q194884



SUMMARY
When you are developing a solution with Microsoft Outlook 98, you may want to enable or disable the Outlook toolbars and window panes programmatically. This article illustrates how you can automate this in Outlook.



MORE INFORMATION
The following Microsoft Visual Basic or Visual Basic for Applications subroutine resets Outlook to the default Outlook user interface settings. This environment will persist in Outlook until changed by the user or code.

The State property determines whether the toolbar is visible. If the state of the button is up (msoButtonUp) then the toolbar is not displayed. If the state of the toolbar button is down then the toolbar is visible.

Prior to running this code, be sure to reference the Microsoft Outlook 98 Object Library and the Microsoft Office 8.0 Object Library. Outlook must also be currently running. Sub ResetOutlookUserInterface

Dim outapp As Outlook.Application Dim olns As Outlook.NameSpace Dim MyExplorer As Outlook.Explorer Dim MyMenu As CommandBar Dim MyCmd As CommandBarControl

Set outapp = New Outlook.Application Set olns = outapp.GetNamespace("MAPI") Set MyInbox = olns.GetDefaultFolder(olFolderInbox)

' Get the active application-level window displayed Set MyExplorer = outapp.ActiveExplorer

' Reference the View menu Set MyMenu = MyExplorer.CommandBars.Item("View")

' Display the Outlook Bar Set MyCmd = MyMenu.Controls("Outlook Bar") If MyCmd.State = msoButtonUp Then MyCmd.Execute

' Hide the Folder List Set MyCmd = MyMenu.Controls("Folder List") If MyCmd.State = msoButtonDown Then MyCmd.Execute

' Display the Standard toolbar Set MyCmd = MyMenu.Controls("Toolbars").Controls("Standard") If MyCmd.State = msoButtonUp Then MyCmd.Execute

' Hide the Advanced toolbar Set MyCmd = MyMenu.Controls("Toolbars").Controls("Advanced") If MyCmd.State = msoButtonDown Then MyCmd.Execute

' Hide the Remote toolbar Set MyCmd = MyMenu.Controls("Toolbars").Controls("Remote") If MyCmd.State = msoButtonDown Then MyCmd.Execute

' Hide the preview pane Set MyCmd = MyMenu.Controls("Preview Pane") If MyCmd.State = msoButtonDown Then MyCmd.Execute

' Display the status bar Set MyCmd = MyMenu.Controls("Status Bar") If MyCmd.State = msoButtonUp Then MyCmd.Execute

Set MyCmd = Nothing Set MyMenu = Nothing Set MyExplorer = Nothing Set olns = Nothing Set outapp = Nothing

End Sub

