아웃룩 주소록의 성명 표시 방법과 이메일 표시 이름 필드를 한꺼번에 수정해 주는 매크로입니다.
성명 표시 방법과
이메일 표시 방법이 다음과 같이 일괄 변경됩니다.
- 영문 이름인 경우: 성, 이름 (회사명) / 성, 이름 (이메일주소)
- 한글 이름인 경우: 성이름 (회사명) / 성이름 (이메일주소)
아래는 변경된 예입니다. (이미지를 클릭하면 크게 보임)
실행 방법은 다음과 같습니다.
아웃룩(2007기준) 메뉴의 [도구]-[매크로]-[매크로]로 가시거나, Alt+F8을 누르시면 매크로 추가 및 실행 창이 아래와 같이 나옵니다.
새로운 매크로 이름을 '주소록표시방법변경'이라고 입력한 뒤 '편집'을 클릭하고, 아래의 코드를 복사해 넣으면 됩니다.
복사해 넣을 코드 보기..
Sub 주소록표시방법변경()
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objContact As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim objContactsFolder As Outlook.MAPIFolder
Dim obj As Object
Dim strFirstName As String
Dim strLastName As String
Dim strName As String
On Error Resume Next
Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objItems = objContactsFolder.Items
For Each obj In objItems
'Test for contact and not distribution list
If obj.Class = olContact Then
Set objContact = obj
With objContact
strFirstName = .FirstName
strLastName = .LastName
If (Asc(Left(strFirstName, 1)) >= 65 And Asc(Left(strFirstName, 1))) Then
strName = strLastName + ", " + strFirstName
Else
strName = strLastName + strFirstName
End If
.FileAs = strName + IIf(.CompanyName <> "", " (" + .CompanyName + ") ", "")
If (.Email1Address <> "" And strName <> "") Then
.Email1DisplayName = strName + " (" + .Email1Address + ")"
End If
If (.Email2Address <> "" And strName <> "") Then
.Email2DisplayName = strName + " (" + .Email2Address + ")"
End If
If (.Email3Address <> "" And strName <> "") Then
.Email3DisplayName = strName + " (" + .Email3Address + ")"
End If
.Save
End With
End If
Err.Clear
Next
Set objOL = Nothing
Set objNS = Nothing
Set obj = Nothing
Set objContact = Nothing
Set objItems = Nothing
Set objContactsFolder = Nothing
End Sub
참고로 위 코드를 실행하기 위해서는 메뉴의 [도구]-[매크로]-[보안]을 열어 '모든 매크로에 대해 경고 표시' 또는 그 이하의 보안 설정이 되어 있어야 합니다.
이 매크로는 수정본이며
원본은 이곳에서 가져왔습니다.
이 수정 본이 원본과 다른 점은 '이메일 표시 이름'까지 일괄 변경해 준다는 점입니다.