L
Lucian Sitwell
This macro previously worked without any problem. Yesterday, when
installing a new Palm Zire, the contacts got accidentally deleted, but I had
them backed up. Now this macro doesn't work. This macro accesses
information in outlook from word.
I get a type 13 error mismatch at the line: Set objItem =
objContacts.Items.Item(1)
Any ideas what changed??????
Using Office 2003 on a Dell 600M.
Lucian Sitwell
=================================
Sub test2()
'
' test2 Macro
' Macro created 1/4/2005 by Lucian Sitwell
'
' Test Macro
' Macro recorded 12/15/2004 by Lucian Sitwell
'
Dim olApp As Outlook.Application
Dim objContact As Object
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objAddress As Object
Dim objInspector As Outlook.Inspector
Dim objExplorer As Outlook.Explorer
Dim objItem As Outlook.ContactItem
Dim strSalutation As String
'Create an instance of Outlook
Set olApp = CreateObject("outlook.application")
Set objNameSpace = olApp.GetNamespace("MAPI")
'Sets up a folder of contacts
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
'Finds a specific record in Contacts
Set objContact = objContacts.Items.Find("[FullName] = ""Dr. Steven T.
Bencze""")
Set objInspector = olApp.ActiveInspector
Set objItem = objContacts.Items.Item(1)
'If the NickName field isn't blank, then write Dear + nickname
'Otherwise, write Dear Title + Last Name
If objContact.NickName <> "" Then
strSalutation = "Dear " & objContact.NickName & ", "
Else
strSalutation = "Dear " & objContact.Title & " " &
objContact.LastName & ": "
End If
Selection.TypeText objContact.FullName
Selection.TypeParagraph
Selection.TypeText objContact.MailingAddress
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:=strSalutation & vbCr & vbCr
End Sub
installing a new Palm Zire, the contacts got accidentally deleted, but I had
them backed up. Now this macro doesn't work. This macro accesses
information in outlook from word.
I get a type 13 error mismatch at the line: Set objItem =
objContacts.Items.Item(1)
Any ideas what changed??????
Using Office 2003 on a Dell 600M.
Lucian Sitwell
=================================
Sub test2()
'
' test2 Macro
' Macro created 1/4/2005 by Lucian Sitwell
'
' Test Macro
' Macro recorded 12/15/2004 by Lucian Sitwell
'
Dim olApp As Outlook.Application
Dim objContact As Object
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objAddress As Object
Dim objInspector As Outlook.Inspector
Dim objExplorer As Outlook.Explorer
Dim objItem As Outlook.ContactItem
Dim strSalutation As String
'Create an instance of Outlook
Set olApp = CreateObject("outlook.application")
Set objNameSpace = olApp.GetNamespace("MAPI")
'Sets up a folder of contacts
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
'Finds a specific record in Contacts
Set objContact = objContacts.Items.Find("[FullName] = ""Dr. Steven T.
Bencze""")
Set objInspector = olApp.ActiveInspector
Set objItem = objContacts.Items.Item(1)
'If the NickName field isn't blank, then write Dear + nickname
'Otherwise, write Dear Title + Last Name
If objContact.NickName <> "" Then
strSalutation = "Dear " & objContact.NickName & ", "
Else
strSalutation = "Dear " & objContact.Title & " " &
objContact.LastName & ": "
End If
Selection.TypeText objContact.FullName
Selection.TypeParagraph
Selection.TypeText objContact.MailingAddress
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:=strSalutation & vbCr & vbCr
End Sub