Building Active Directory Based Outlook Signatures – Update

Looking through our corporate Global Address List last night after posting my original article at http://richardjgreen.net/2012/02/24/building-active-directory-based-outlook-signatures/, I discovered a couple of special case users.

In our company, we have two users with identical names, so to differentiate between them, their names in Active Directory have been modified to include their department as a trailing item.

Looking through our corporate Global Address List last night after posting my original article at http://richardjgreen.net/2012/02/24/building-active-directory-based-outlook-signatures/, I discovered a couple of special case users.

In our company, we have two users with identical names, so to differentiate between them, their names in Active Directory have been modified to include their department as a trailing item. For example:

  • Richard Green (ICT)
  • Richard Green (HR)

In the Outlook signature, it is pretty redundant having this included in the name as the department is shown on the following line, so I’ve added a new section to the script which will trim this information.

Firstly, you need to update the Dim statement at the top of the script to include a new integer.

Dim intNameLen

Once you have declared the integer, add the following section. I’ve added it between the existing country specific configuration and the phone number internationalisation sections, but so long as it gets defined before the building of the signature it will work.

If InStr(1, strName, "(") > 0 Then
    intNameLen = InStr (strName, "(")
    intNameLen = intNameLen -2
    strName = Left(strName, intNameLen)
Else
End If

First, we need to look to see if an opening bracket exists in the string using InStr. If there is a bracket present then we move into the If statement, otherwise we move into the empty Else statement and then continue through the script.

Within the If statement, first, we find the character position of the opening bracket using InStr again, but this time we push the value into the intNameLen integer variable. Next, we need to take into account that InStr will return the position of the bracket itself, but as we want to remove the space between the name and the bracket symbol we need to reduce the value of the intNameLen variable by two.

Once we’ve subtracted two from the value, we can use Left to retrieve the value of the strName variable, but only the name portion by excluding the trailing department tag, then save the name back into the strName variable.