
Stumpted trying to set user fields
I have a set of users who have a common Contacts folder that I need to clean
up. One thing I need to do is find a user name which has been set up as a
category and put the name and an associated number into contacts User
Fields. There are 29 of these users, and I plan a select case statement to
deal with them in one fell swoop.
So I ran a test using an If statement to deal with one of my 29 users, and
if the code worked I'd write the select statement. The code also sets the
File As field and takes UK out of the address so we don't look daft when
doing mailings.
BUT I get an Object Required error when the code runs...
Sub updateJRDBUserFields()
Dim appOL As Outlook.Application
Dim nmsNS As NameSpace
Dim fldJRDBase As MAPIFolder
Dim itmItems As Items
Dim itmContact As Object
Dim strCats As String
Set appOL = CreateObject("Outlook.Application")
Set nmsNS = appOL.GetNamespace("MAPI")
Set fldJRDBase = nmsNS.GetDefaultFolder(olFolderContacts).Folders(JRDB)
Set itmItems = fldJRDBase.Items
For Each itmContact In itmItems
Item.FileAs = Item.LastName & ", " & Item.FirstName
Set strCats = itmContact.Categories {Error here: Object required}
If InStr("Cheryl Robins", strCats) Then
itmContact.User1 = "Cheryl Robins"
itmContact.User2 = "165"
End If
If .BusinessAddressCountry = "United Kingdom" Then
.BusinessAddressCountry = ""
End If
.Save
End Sub
Any help will be gratefully received - teaching oneself VBA can be a lonely
process at times.
Ollie