Tuesday, 9 July 2013

How to count members in distribution list – ms outlook




Follow below mentioned process to count members in any distribution list. There isn’t any inbuilt option in MS outlook to count members. By following process, a new tool button can be created for macro which auto counts the total members in selected distribution list.

1. Start Outlook
2. Click Tools > Macro > Visual Basic Editor
3. If not already expanded, expand Microsoft Office Outlook Objects
4. If not already expanded, expand Modules
5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6. Copy the following code and paste it into the right-hand pane of Outlook’s VB Editor Window.


----Copy the following code----

Option Explicit

Public Sub ShowMemberCount()
Dim obj As Object
Dim DL As Outlook.DistListItem

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
If Application.ActiveExplorer.Selection.Count Then
Set obj = Application.ActiveExplorer.Selection(1)
End If
Else
Set obj = Application.ActiveInspector.CurrentItem
End If

If Not obj Is Nothing Then
If TypeOf obj Is Outlook.DistListItem Then
Set DL = obj
MsgBox "Name: " & DL.DLName & _
vbCrLf & "Member: " & DL.MemberCount, _
, "Member Count"
End If
End If
End Sub
---------Till here--------

7. Click the diskette icon on the toolbar to save the changes
8. Close the VB Editor

Using the Code. The code is simple to use. After opening or selecting a distribution list run the macro. It’ll display a dialog-box that shows the number of members the list is composed of.



0 comments:

Post a Comment