ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save contact to a particular folder in Outlook (https://www.excelbanter.com/excel-programming/409546-save-contact-particular-folder-outlook.html)

mathew

Save contact to a particular folder in Outlook
 
I need some help! I have the VBA code going together ok. Im 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, Im not a computer programmer, Im an Engineer,
can you hear Bones talking to Kirk?

Ok, the problem. I have this VBA code Ive 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 Im 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, Ive 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("C ontacts1")

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



All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com