Copying fields in batch?

  • Thread starter Thread starter Hubby
  • Start date Start date
H

Hubby

Hello,

I have my secretary type in contact information. While doing so, she
inadvertently used the "category" field, instead of creating a
separate user-defined "project" field, to input the project that I
worked on with the person.
Now, as the "category" field has its original purpose and I need to
reserve it, what I'm trying to do is copy all information in the
"category" field into the "project" field.

What VBA command should I use to copy fields in batch?
 
Hi Hubby,

the procedure loops through a folder you need to select and copies all
categories of each contact into an userdefined field named "projects".

Place the cursor in the first sub and press F5 to start.

'<DieseOutlookSitzung>
Public Sub LoopContactFolder()
On Error GoTo ERR_HANDLER
Dim oFld As Outlook.MAPIFolder
Dim obj As Object

Set oFld = Application.Session.PickFolder
If Not oFld Is Nothing Then
For Each obj In oFld.Items
If TypeOf obj Is Outlook.ContactItem Then
CopyCategoryToUserProp obj
End If ' -> select this line and press F9
Next
End If
Exit Sub
ERR_HANDLER:
MsgBox Err.Description, vbExclamation
End Sub

Public Sub CopyCategoryToUserProp(oContact As Outlook.ContactItem)
Dim oProp As Outlook.UserProperty

If Len(oContact.Categories) Then
Set oProp = oContact.UserProperties("Projects")
If oProp Is Nothing Then
Set oProp = oContact.UserProperties.Add("Projects", olText)
End If
oProp.Value = oContact.Categories
oContact.Save
End If
End Sub
'</DieseOutlookSitzung>
 
Back
Top