View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
michelxld[_36_] michelxld[_36_] is offline
external usenet poster
 
Posts: 1
Default VBA code to create new Contacts field in Outlook


Hello Paul

sorry , i don't undersand your question

this example controls if a UserProperty named "MyCustomField" exist
(for all contatcs) , and add it if does not exist


Sub control_Or_Add_userProperty_contactsOutlook()
'activate Microsoft Outlook xx.x Object Library
Dim olApp As New Outlook.Application
Dim Cible As Outlook.contactItem
Dim dossierContacts As Outlook.MAPIFolder
Dim myProp As Outlook.UserProperty

Set olApp = New Outlook.Application
Set dossierContacts =
olApp.GetNamespace("MAPI").GetDefaultFolder(olFold erContacts)

For Each Cible In dossierContacts.Items
Set myProp = Cible.UserProperties("MyCustomField")

If myProp Is Nothing Then
Set myProp = Cible.UserProperties.Add("MyCustomField", olText)
myProp.Value = "My data"
Cible.Save
End If

Next
End Sub


Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=478209