vba error when referencing the FullName of a contact

G

GlenD

I am getting a number of what appear to strange errors.

The following code plus some debug MsgBox statements iare erroring out
and I am looking for some suggestion as to why this might be
Error indicated below at the ******<- code stops with an runtime
error: Method FullName of ContactItem failed *****.


Code from VBA help

Sub UseEntryID()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.MAPIFolder
Dim myItem1 As Object
Dim myItem2 As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
Set myItem1 = myContacts.Items.GetFirst
Set myItem2 = myContacts.Items.GetNext
MsgBox " myItem1 and myItem 2 are the following types " &
TypeName(myItem1) & " - " & TypeName(myItem2)
Set myItem1 = myContacts.Items.Find("[FirstName] = ""Glen""")
MsgBox " Name is " & myItem1.FullName ******<- code stops
with an runtime error: Method FullName of ContactItem failed *****.
Set myItem2 = myContacts.Items.Find("[FileAs] = ""Duval"" and
[FirstName] = ""Glen""")
MsgBox " Name is " & myItem2.FullName

If Not TypeName(myItem2) = "Nothing" Then
If myItem1.EntryID = myItem2.EntryID Then
MsgBox "These two contact items refer to the same
contact."
End If
Else
MsgBox "The contact items were not found."
End If
End Sub
 
S

Sue Mosher [MVP-Outlook]

You should always check whether an actual item is present, e.g. If Not myItem1 Is Nothing Then

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top