![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
I don't see any statement to save the item after you make the changes to it.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message oups.com... 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 |
#3
|
|||
|
|||
![]()
Thanks for the info. Didn't know you had to save;
you wouldn't know what the statement is; it will avoid me a ride on Google. Regards Al Sue Mosher [MVP-Outlook] wrote: I don't see any statement to save the item after you make the changes to it. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message oups.com... 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 |
#4
|
|||
|
|||
![]()
After a little bit of thinkering I figured out the save. Still have one
problem though; I need to differentiate between a contact entry and a distribution list entry the line ' If objContact Is OlItemType.olContactItem Then' which doesn't work is what I would like to do. The revised version of the code now stands as follows: 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 updTakenPlace As Boolean Set olApp = CreateObject("Outlook.Application") Set objNameSpace = olApp.GetNamespace("MAPI") Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts) For Each objContact In objContacts.Items If objContact Is OlItemType.olContactItem Then updTakenPlace = False For Each objProperty In objContact.UserProperties If objProperty.Name "LoginName" Then 'MsgBox objProperty.Name objProperty.Delete updTakenPlace = True End If Next objProperty Set objProperty = Nothing If updTakenPlace Then objContact.Save End If End If Next objContact Set objContact = Nothing End Sub Thanks, Al Sue Mosher [MVP-Outlook] wrote: I don't see any statement to save the item after you make the changes to it. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message oups.com... 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 |
#5
|
|||
|
|||
![]()
A "statement" is a line of code (or lines of code joined by the underscore (_) character).
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message ups.com... Thanks for the info. Didn't know you had to save; you wouldn't know what the statement is; it will avoid me a ride on Google. Regards Al Sue Mosher [MVP-Outlook] wrote: I don't see any statement to save the item after you make the changes to it. "acb" wrote in message oups.com... 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 |
#6
|
|||
|
|||
![]()
Try:
Dim objItem as Object snip For Each objItem In objContacts.Items If objItem.Class = olContact Then Set objContact = objItem etc -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message ups.com... After a little bit of thinkering I figured out the save. Still have one problem though; I need to differentiate between a contact entry and a distribution list entry the line ' If objContact Is OlItemType.olContactItem Then' which doesn't work is what I would like to do. The revised version of the code now stands as follows: 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 updTakenPlace As Boolean Set olApp = CreateObject("Outlook.Application") Set objNameSpace = olApp.GetNamespace("MAPI") Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts) For Each objContact In objContacts.Items If objContact Is OlItemType.olContactItem Then updTakenPlace = False For Each objProperty In objContact.UserProperties If objProperty.Name "LoginName" Then 'MsgBox objProperty.Name objProperty.Delete updTakenPlace = True End If Next objProperty Set objProperty = Nothing If updTakenPlace Then objContact.Save End If End If Next objContact Set objContact = Nothing End Sub |
#7
|
|||
|
|||
![]()
Thanks. Worked as I had expected.
Regards, Al Sue Mosher [MVP-Outlook] wrote: Try: Dim objItem as Object snip For Each objItem In objContacts.Items If objItem.Class = olContact Then Set objContact = objItem etc -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "acb" wrote in message ups.com... After a little bit of thinkering I figured out the save. Still have one problem though; I need to differentiate between a contact entry and a distribution list entry the line ' If objContact Is OlItemType.olContactItem Then' which doesn't work is what I would like to do. The revised version of the code now stands as follows: 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 updTakenPlace As Boolean Set olApp = CreateObject("Outlook.Application") Set objNameSpace = olApp.GetNamespace("MAPI") Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts) For Each objContact In objContacts.Items If objContact Is OlItemType.olContactItem Then updTakenPlace = False For Each objProperty In objContact.UserProperties If objProperty.Name "LoginName" Then 'MsgBox objProperty.Name objProperty.Delete updTakenPlace = True End If Next objProperty Set objProperty = Nothing If updTakenPlace Then objContact.Save End If End If Next objContact Set objContact = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Fields | Dan | Outlook - Using Contacts | 2 | May 27th 06 12:36 AM |
New message To, CC, BCC and Subject fields don't accept 'delete' | [email protected] | Outlook - General Queries | 3 | May 25th 06 07:34 PM |
formating multiple fields creates duplicate fields | [email protected] | Outlook - Using Forms | 0 | April 18th 06 03:59 PM |
Some fields cannot be edited on "All Fields" tab on Contact forms | BR | Outlook - Using Contacts | 1 | February 19th 06 07:54 PM |