Downloads
15730.zip

One annoying aspect of Microsoft Outlook is that its user interface (UI) doesn't always behave consistently. For example, open the Inbox and Calendar folders in separate windows. Then, close Outlook by clicking File, Exit and Log Off. When you restart Outlook, the separate Inbox and Calendar windows reopen. Now, try the same operation with the Inbox and a Microsoft Exchange Server public folder in separate windows. When you restart Outlook, Outlook doesn't remember that the public folder was open and instead displays the Inbox folder in the extra window.

This annoyance is a prime target for an Outlook 2000 VBA routine that runs when Outlook starts. The routine depends on a shortcut group on the Outlook Bar that contains shortcuts to the folders you want to open when Outlook starts—similar to the Startup group on the Programs menu. Right-click the Outlook Bar, and choose Add New Group. Name the group Startup Folders. Add to the Startup Folders group any folders (besides the Inbox) that you want to appear when Outlook starts.

Now, add the code you see in Listing 1 to your Outlook VBA project's built-in ThisOutlookSession module. This code for the Application_Startup event handler runs the ShowMyFolders subroutine (which you see in Listing 2), then makes the most recently loaded window the active window. This window is either the Inbox or another default folder that you have set to open when Outlook starts.

Put the code in Listing 2 in the ThisOutlookSession module or in a separate module. The ShowMyFolders procedure checks for the existence of a Startup Folders group. If it finds one, it uses the TypeName() function to test whether each shortcut in the group represents a MAPIFolder object (i.e., an Outlook folder). For Web URL shortcuts on the Outlook Bar, TypeName() returns "String"; for system folder shortcuts, the function returns "Object". The code ignores any shortcuts to system folders or Web pages because Outlook doesn't provide a programmatic method to display a non-Outlook folder in an Outlook window.

You can customize Listing 2's code in two ways. First, you can control which navigation panes Outlook displays in the Explorer window. By supplying the Add method's second argument with the intrinsic constant olFolderDisplayNoNavigation, Listing 2's code sets the window to show neither the Outlook Bar nor the folder list. Other possible values are olFolderDisplayFolderOnly (i.e., show the folder list) and olFolderDisplayNormal (i.e., show the Outlook Bar).

You can also customize the state of the Explorer window. Listing 2's code minimizes the window:

objExpl.WindowState =   olMinimized

The other choices besides olMinimized are olMaximized and olNormalWindow.

After you add this code to your VBA project, whenever you start Outlook, separate windows will open for each of the Outlook folders in the Startup Folders group on the Outlook Bar. By the way, if you want Outlook to start in a default folder other than the Inbox, choose Tools, Options, then switch to the Other tab and click Advanced Options. You'll see the Startup in this folder list at the top of the dialog box.