How to use this VBA procedure to reset Outlook view settings each time you launch

Regardless of why you lose your favorite Microsoft Outlook view settings, it's easy to reclaim them with this simple macro.

Reset Word In Wooden Cube

Image: SinArtCreative, Getty Images/iStockphoto

Microsoft Outlook is extremely flexible with its view setting--not only can you control what you see, or don't see, you can create several views. That way, you can switch between views that support your different work tasks.

With all that viewing going on, you might end up with obscure settings when you launch Outlook the next time. That means before you can start working, most likely, you'll spend time resetting things. You could easily reset the view or, by using a simple macro, you can guarantee that Outlook starts with the view you want to use when you start working. This is also a good idea if you support users who are easily confused by random settings and options. 

I'm using Outlook 365 on a Windows 10 64-bit system, but this will work in older versions. You can download the ThisOutlookSession.cls file and import it into Outlook rather than entering the code yourself. Don't try to paste the code from this web page--the Visual Basic Editor (VBE) won't be able to run it correctly. VBA code won't run in a browser version.

LEARN MORE: Office 365 Consumer pricing and features

How to reset your security macro settings 

Out of the box, Office 365 is protective and disables all macros. Before you can run a macro, you'll need to reset your security macro settings unless you've already done so. Follow these steps to reset your security macro settings.

  1. Click the File tab, choose Options, and then click Trust Center in the left pane.
  2. Click the Trust Center Settings button in the Microsoft Outlook Trust Center section.
  3. In the left pane, click Macro Settings.
  4. In the Macro Settings, click Notifications For All Macros (Figure A). At a later date, you might want to change this, but for now, it gives you the most control and protection while also allowing the macro to run.
  5. Click OK twice.

Figure A

outlook-ax.jpg

Change your macro settings.

It's worth noting that changing your macro settings comes with a bit of risk. Using the notification setting will allow Outlook to run macros, but it will prompt you first. You can choose not to enable macros at the prompt.

How to create a simple demonstration view

A view can have lots of settings, but we'll keep this one simple. Creating a view isn't the purpose of this article--setting it when you launch Outlook is. If you already have a named view that you work with, you can use it. Or, follow these steps to create a simple demonstration view.

  1. Select a folder, probably the Inbox for most users.
  2. Click Change View in the Current View group and choose Manage Views.
  3. In the resulting dialog, click New. (You could also select an existing view and click Modify.)
  4. Enter a name, such as ResetAtStartup (Figure B) and click OK.
  5. Click Columns and using Add and Remove set the columns you want in the view (Figure C). Click OK when you're done.
  6. Use the rest of the options to set the view properties you want to see in your startup view. (We will not set anything specific--I just want you to know where to find these options and how to name a view.)
  7. Click OK twice.

Figure B

outlook-b.jpg

Give the view a meaningful name.

Figure C

outlook-c.jpg

Add columns to the view. 

You now have a view with the specific settings and option you want in play when you launch Outlook. We'll refer to the view's name, ResetAtStartup, in the macro. 

The macro

To reset the view when you launch Outlook, you'll use VBA's Startup event; specifically, that event will call a procedure that resets the view. You could reset the view within the Startup event, but because you might want to use that event for other things, it's best to call a separate procedure.

To create the macro, press Alt+F11 to open the Visual Basic Editor (VBE). Then, follow these steps.

  1. Select ThisOutlookSession in the Project window (to the left). If it isn't visible, choose Project Window from the View menu.
  2. Enter the code shown in Listing A.
  3. Save your work and then close the VBE. 
  4. Close Outlook and then launch Outlook again.   

Listing A

Public Sub Application_Startup()
Run when launching Outlook.
Call ResetView
End Sub
Sub ResetView()
Reset the view to ResetAtStartup.
Dim objViews As Views
Dim objView As View
Work with current folder.
Set objViews = Application.ActiveExplorer.CurrentFolder.Views
Identify the view.
Set objView = objViews.Item("ResetAtStartup")
Apply the view.
objView.Apply
MsgBox "It worked"
End Sub

The Startup event will call ResetView(), but nothing will happen until Outlook has added all its add-ins. To see that the VBA procedure worked, click the View tab and then click Change View. The selected view (Figure D) is ResetAtStartup.

Figure D

outlook-d.jpg

The VBA procedure set the view to ResetAtStartup. 

It's rather simple. The Startup event calls ResetView, which defines and declares a few variables. The second Set statement identifies the demonstration view you created at the beginning of this article, ResetAtStartup. The next statement applies that view. The MsgBox() then displays a simple message to show it all worked. You can delete this last statement when applying this procedure to your own work—it's just there for show.

Although this macro is meant to reset the view when launching, the view is always available. Click the View tab and choose ResetAtStartup from the Change View dropdown in the Current View group. The macro resets things, so you or your users are ready to go.

Send me your Microsoft Office question

I answer readers' questions when I can, but there's no guarantee. Don't send files unless requested; initial requests for help that arrive with attached files will be deleted unread. You can send screenshots of your data to help clarify your question. When contacting me, be as specific as possible. For example, "Please troubleshoot my workbook and fix what's wrong" probably won't get a response, but "Can you tell me why this formula isn't returning the expected results?" might. Please mention the app and version that you're using. I'm not reimbursed by TechRepublic for my time or expertise when helping readers, nor do I ask for a fee from readers I help. You can contact me at susansalesharkins@gmail.com.

Also see

Affiliate disclosure: TechRepublic may earn a commission from the products and services featured on this page.