vba error when referencing the FullName of a contact

  • Thread starter Thread starter GlenD
  • Start date Start date
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
 
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
 
Back
Top