Save contact to a particular folder in Outlook

M

Mathew

I need some help! I have the VBA code going together ok. I’m sure like most
of you every time the code is done someone always say: Gee I wish it could…â€
Inevitably, the manager likes the idea and thus new work is created for us
poor slobs. Unfortunately, I’m not a computer programmer, I’m an Engineer,
can you hear Bones talking to Kirk?

Ok, the problem. I have this VBA code I’ve been working on for a couple
weeks. We use Excel 2003. Our contacts, which we keep in Excel, change
daily. 1st exercise was to create a macro to update Outlook contacts when a
new one can in. I thought the code was done, but no! The 2nd change was to
give the user the option to delete the old one. I thought I’m done again,
but no!! Well now they want me to be able to send the contact to a subfolder
under Contacts in Outlook. Ther folder will be called "Lazy" in honor of my
co-workers. Anyway, I’ve re-read Automating Outlook with Excel at Dick
Clicks http://www.dicks-clicks.com/excel/olAutomating.htm very good site.
I've some others as well. I have not yet found a way for saving the contact
to a subfolder under my Contacts in Outlook. How can I access or create this
subfolder? Below is some of the code.

For Each rCell In Range("A4:A580").Cells
Set olApp = CreateObject("Outlook.Application")
If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.application")
End If

Set olCi = olApp.CreateItem(olContactItem)

OrganizationalIDNumber = rCell.Value ' Company long # i.e. AB001..
Department1 = rCell.Offset(0, 1).Value ' Company Short Name
……

With olCi
.AssistantName = AssistantName1 ' Assistants Name
.CompanyName = Company ' Company Name
……
.Save
End With
Set olCi = Nothing
Set olApp = Nothing
Next rCell

I changed the line Set Olci to:
Set olCi = olApp.CreateItem(olContactItem).Folders("contacts1")
But I get error 438. So this is not the correct way to access the object.

Among the other attempts I also tried:
Set Fldr = olNs.GetDefaultFolder(olFolderContacts).Folders("Contacts1")

I’m sure this is simple for you guys, but my hairline is almost gone! Any
help would be appreciated!
 

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