I am trying to build a module to add notes etc to an outlook contact.
I have tried a number of things and the code below works.
Lines commented out generated errors.
Why does
fail when so many examples use it?
How can I specify different folder for the contacts?
any help appreciated
I have tried a number of things and the code below works.
Lines commented out generated errors.
Why does
Code:
Dim olApp As Outlook.Application
How can I specify different folder for the contacts?
Code:
Sub GetContact()
Dim int1 as integer
Dim str1 As String, str2 As String
'Dim olApp As Outlook.Application
'Dim olNs As Namespace
'Dim Fldr As MAPIFolder
'Dim olCi As ContactItem
Dim olApp As Object
'On Error GoTo Error_Handler '''''' need to add code for this top work
Const olContactItem = 2
Const olFolderContacts = 10
Set olApp = CreateObject("Outlook.Application")
Set olContact = olApp.CreateItem(olContactItem)
'Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.Folders("Personal Folders").Folders("Contacts")
int1 = 1
For Each olCi In Fldr.Items
str1 = olCi.CompanyName
Sheets(ActiveSheet.Name).Cells(int1, 1) = str1
str2 = olCi.FullName
Sheets(ActiveSheet.Name).Cells(int1, 2) = str2
int1 = int1 + 1
Next olCi
Set olCi = Nothing
Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub
any help appreciated