When you find that several items are opened in your Outlook, you may wish to close the items but the current item. Without any doubts, closing them one by one is quite troublesome. So this article will teach you how to use VBA to close them in one go.
You must have ever kept several items open in your Outlook at the same time. In this case, not only will you find that your Outlook performs slowly, but also it will clutter up your works. Therefore, it is suggested that you’d better close the items which are not required timely.
Actually, Outlook comes endowed with a native feature – “Close All Items”, which permits you to close all the opened items via one button. However, by this means, the current item which you are composing or reading will be closed as well. Thus, if you would like to close all the other opened items but the current item, “Close All Items” feature isn’t the best choice. It’s advisable to use the following method which is applying Outlook VBA.
Close All Open Items Except the Current One
- In the first place, start your Outlook program.
- Then you need to shift to “Developer” tab. If you don’t find this tab, you need to enable it by customizing ribbon in “Outlook Options”.
- Next under this tab, click on the “Visual Basic” button.
- Subsequently, you will enter the Outlook VBA editor window in success.
- After that, you ought to open a module that is not in use.
- Then copy and paste the following VBA codes into such a module.
Sub CloseAllOtherOpenedItemsButCurrentItem() Dim objInspectors As Outlook.Inspectors Dim objCurrentItem As Object Set objInspectors = Outlook.Application.Inspectors If objInspectors.Count > 0 Then Set objCurrentItem = Outlook.Application.ActiveInspector.CurrentItem 'Close all the opened items While objInspectors.Count > 0 objInspectors.Item(1).Close olPromptSave Wend 'Keep the current item opened objCurrentItem.GetInspector.Activate End If End Sub
- Later you can add the new VBA project to the Quick Access Toolbar.
- Firstly, back to main Outlook window.
- Then go to “File” menu and select “Options”.
- Next switch to “Quick Access Toolbar” tab.
- After that, follow the steps shown in the image below to complete it.
- Finally, you can have a try. Click the macro button in Quick Access Toolbar. At once, all the other opened items will be closed, but the current item will be kept opened.
Dispose of Various PST Problems Flexibly
Since Outlook PST file is susceptible to errors and corruption, you should keep well-prepared for various unexpected issues. For instance, you need to get hold of a robust PST repair tool, like DataNumen Outlook Repair, which can help you extract maximum PST data from the corrupt Outlook PST file. Moreover, you need to make regular backups for your Outlook PST data.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql corruption and outlook repair software products. For more information visit www.datanumen.com