Object Types don't match message 
Author Message
 Object Types don't match message

Hi all,

I'm trying to find and efficient method of selecting a contact based on its
name and found some code that seems to do it.

In the following codesample, I get a types don;t match error when i remove
the debug.print statement. With the debug.print it seems to function
allright. It seems inefficient to me to leave it there, since I only put it
there for debugging reasons. Can anyone please solve this puzzle and give me
a sollution? I can't declare objItem as ContactItem, because then i get a
runtime error on the object colItems. If there is a better method to find a
contact based on an attribute-value I would be very interested also.
Thanks very much in advance.

The declaration of object:

    Dim olItem         As Outlook.ContactItem
    Dim colItems      As Items
    Dim objItem       As Object
    Dim olNameSpace   As Outlook.NameSpace
    Dim olFolder      As Outlook.MAPIFolder
    Dim olNewFolder   As Outlook.MAPIFolder

        Set olItem = Nothing
        strWhere = "[FileAs] = " & """" & strItemName & """"
        Set colItems = olNewFolder.Items.Restrict(strWhere)
        colItems.SetColumns ("FileAs")
        For Each objItem In colItems
            ' must test for item type to avoid distribution lists
            If TypeName(objItem) = "ContactItem" _
            Then
                If objItem.FileAs = strItemName _
                Then
                    Debug.Print "Item = " & objItem
                    Set olItem = objItem
                    Exit For
                End If
            End If
        Next

Kind regards,
Hans



Sat, 30 Jul 2005 08:59:40 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Finding records that don't match

2. Names don't match posts

3. SDK, components, and actual devices don't match up

4. Object does not match target type

5. VBA - ActiveX designer's type Information does not match what was saved

6. don't show this message again

7. Don't read this message!

8. Don't read this message!

9. Messages made with CDO don't sync to OST

10. scriptcontrol error messages don't say what function they are in

11. Don't read this message!

12. Just a test message Don't read

 

 
Powered by phpBB® Forum Software