A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Delete some UD fields



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 17th 06, 06:18 PM posted to microsoft.public.outlook.program_vba
acb
external usenet poster
 
Posts: 6
Default Delete some UD fields

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  
Old June 17th 06, 08:24 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Delete some UD fields

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  
Old June 18th 06, 06:29 AM posted to microsoft.public.outlook.program_vba
acb
external usenet poster
 
Posts: 6
Default Delete some UD fields

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  
Old June 18th 06, 07:05 AM posted to microsoft.public.outlook.program_vba
acb
external usenet poster
 
Posts: 6
Default Delete some UD fields

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  
Old June 18th 06, 11:38 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Delete some UD fields

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  
Old June 18th 06, 11:41 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Delete some UD fields

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  
Old June 19th 06, 07:52 AM posted to microsoft.public.outlook.program_vba
acb
external usenet poster
 
Posts: 6
Default Delete some UD fields

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 03:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.