Outlook cannot count and show you the number of members in your contact groups. Thus if you want to make it to auto count and display the member counts in your contact groups, you have to resort to Outlook VBA. This article will tell you how to realize it.
In the previous article-“2 Methods to Count the Members in Your Outlook Contact Group”, you can learn how to quickly get the number of the members in a contact group with Outlook VBA. It will show you the number in a popup message box. Also, every time you want to get the number, you have to run the VBA project. In some degree, it is indeed a bit troublesome. Why not make Outlook to auto count and show the number of members in a column? Here we will exhibit the concrete VBA codes and the detailed operations.
Auto Display Member Counts in New Contact Groups
- In the first place, launch Outlook and turn to “Contacts” pane.
- Then you should switch to “View” tab and click “Change View” button. From the drop down list, you should enable the “List” view.
- Next you ought to click on “View Settings” button, which will bring out a new dialog box. And then click on “Columns” button.
- After that, in the newly popup “Show Columns” dialog box, click on “New Column”. And then type a name for the new column. Lastly click a series of “OK” until all the dialog boxes are closed.
Notes: Then optionally, you can use “Move Up” and “Move Down” button to change the column order.
- After backing to main Outlook window, you should press “Alt + F11” keys to access VBA editor.
- Subsequently, you should open the “ThisOutlookSession” project and copy the following codes into it.
Public WithEvents olItems As Outlook.Items Private Sub Application_Startup() Set olItems = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items End Sub Private Sub olItems_ItemAdd(ByVal Item As Object) Dim olConGroup As Outlook.DistListItem Dim olProp As Outlook.UserProperty Dim strPropName As String 'The strPropName should be the totally same as the pre-added column strPropName = "MemNumber" Set olProp = Item.UserProperties.Find(strPropName, True) If TypeOf Item Is DistListItem Then Set olConGroup = Item Set olProp = olConGroup.UserProperties.Add(strPropName, olText, True) End If olProp.Value = olConGroup.MemberCount olConGroup.Save End Sub
- Later you ought to sign this code and change your Outlook macro settings to low as normal.
- Eventually you can restart Outlook to activate the VBA project. From now on, when you create a new contact group and save it, the number of members in this group will display in the new column, like the following screenshot:
Display Member Counts in Existing Contact Groups
If you already have many contact groups in your Outlook, then you must hope to show the number of members in the existing groups. The followings are the detailed VBA codes to achieve it.
Sub DisplayContactGroupMemberNumber() Dim obj As Object Dim olConGroup As Outlook.DistListItem Dim olProp As Outlook.UserProperty Dim strPropName As String strPropName = "MemNumber" For Each obj In Application.ActiveExplorer.Selection If TypeOf obj Is DistListItem Then Set olConGroup = obj Set olProp = olConGroup.UserProperties.Add(strPropName, olText, True) olProp.Value = olConGroup.MemberCount olConGroup.Save End If Next End Sub
After copying the VBA codes into a new module, subsequently, you can add the project to Quick Access Toolbar. Then select the existing contact groups and click on the macro button in Quick Access Toolbar. At once, the number of members will be shown in the new column as well.
Watch out for Malicious Macros Hidden in Emails
Since Outlook is vulnerable and malicious email is one of the top threats for Outlook data, you have to keep tabs on those unknown emails from unrecognized sources. Otherwise, once Outlook gets attacked by any viruses, commonly the malicious macros, you will have no choice but to apply an experienced Outlook corruption repair tool, like DataNumen Outlook Repair, to get back your cherished data.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair corrupt SQL Server mdf and outlook repair software products. For more information visit www.datanumen.com