Changing contact by macro

  • Thread starter Alexander Hunziker
  • Start date
A

Alexander Hunziker

Hi

I am trying to write a macro for Outlook XP that changes all my
contact's telephone numbers to a format where they start with "+".
Here's what I did:

Sub ResolveContactAddressViaCheckNames()
Dim ol As Outlook.Application
Dim olns As NameSpace
Dim myContact As Object
Dim Menu As Object
Dim Command As Object
Dim i, j As Long
Dim OldNumber, NewNumber As String


Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")

i = olns.GetDefaultFolder(olFolderContacts).Items.Count
For j = 1 To i
Set myContact =
olns.GetDefaultFolder(olFolderContacts).Items.Item(j)
With myContact
If Not .HomeTelephoneNumber = "" Then
OldNumber = .HomeTelephoneNumber
NewNumber = "+" & OldNumber
myContact.HomeTelephoneNumber = NewNumber
myContact.Save
End If
End With
Next j
End Sub

Unfortunately, the field myContact.HomeTelephoneNumber doesn't get
updated. NewNumber does contain what I want it to contain, though.

Any ideas?

Thanks, Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top