Stumpted trying to set user fields 
Author Message
 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



Sun, 28 Aug 2005 22:07:51 GMT  
 Stumpted trying to set user fields
Which statement triggers the error? Is JRDB the name of the folder? If so, then you omitted the quotation marks around its name:

Set fldJRDBase = nmsNS.GetDefaultFolder(olFolderContacts).Folders("JRDB")

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> 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



Sun, 28 Aug 2005 23:32:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to test (or set) value of user defined yes/no field

2. How to set a User Defined Property for a Field object

3. How to set a User Defined Property for a Field object

4. I have tried and tried.... and tried

5. How do I have a field autoupdate when another field is updated by the user

6. 2101 error when trying to set Left property on text box

7. trying to set archive properties for MAPIFolder

8. Error trying to set relative path on linked powerpoint presentation

9. trying to setting figure format in vba code

10. Trying to set up a diary macro

11. Trying to set the way contacts are stored via FileAs

12. trying to set epn6=en6

 

 
Powered by phpBB® Forum Software