A
acb
Hi,
I have created a few UD fields in Outlook 2003 and would like to delete
them. After some searching, I created the code below. Thing is that it
seems to execute correctly (replacing objProperty.Delete with MsgBox
objProperty.Name pops us values), but upon execution nothing seems to
be happening.
Also, I am getting the error "Run Time Error '13'" - Type mismatch. It
seems that program execution still continues in debug mode. objContact
has a value of Nothing.
Sub DelUDFld()
Dim olApp As Outlook.Application
Dim objContact As Outlook.ContactItem
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objProperty As Outlook.UserProperty
Dim NumItems, i As Integer
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
For Each objContact In objContacts.Items
For Each objProperty In objContact.UserProperties
If objProperty.Name <> "LoginName" Then
'MsgBox objProperty.Name
objProperty.Delete
End If
Next objProperty
Set objProperty = Nothing
Next objContact
Set objContact = Nothing
End Sub
Any help appreciated
Regards,
Al
I have created a few UD fields in Outlook 2003 and would like to delete
them. After some searching, I created the code below. Thing is that it
seems to execute correctly (replacing objProperty.Delete with MsgBox
objProperty.Name pops us values), but upon execution nothing seems to
be happening.
Also, I am getting the error "Run Time Error '13'" - Type mismatch. It
seems that program execution still continues in debug mode. objContact
has a value of Nothing.
Sub DelUDFld()
Dim olApp As Outlook.Application
Dim objContact As Outlook.ContactItem
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objProperty As Outlook.UserProperty
Dim NumItems, i As Integer
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
For Each objContact In objContacts.Items
For Each objProperty In objContact.UserProperties
If objProperty.Name <> "LoginName" Then
'MsgBox objProperty.Name
objProperty.Delete
End If
Next objProperty
Set objProperty = Nothing
Next objContact
Set objContact = Nothing
End Sub
Any help appreciated
Regards,
Al