|
|
Subject:
Office XP, VBA access to City field
Category: Computers > Programming Asked by: whychild-ga List Price: $25.00 |
Posted:
11 Nov 2002 10:11 PST
Expires: 11 Dec 2002 10:11 PST Question ID: 105331 |
I want to iterate through my contacts and modify the City (and other fields). I have tried this... Sub showEntryAttrib() Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") For Each one In myNamespace.AddressLists Debug.Print one.Name For Each two In one.AddressEntries Debug.Print " " + two.Address Debug.Print " " + two.HomeAddressCity Next Next Set myOlApp = Nothing Set myNamespace = Nothing End Sub ... but it throws an error on HomeAddressCity, (two.address works) I'm thinking I need to access the "Contacts" folder and then iterate through contacts there, but the doc is thin.... | |
| |
|
|
Subject:
Re: Office XP, VBA access to City field
Answered By: hammer-ga on 11 Nov 2002 12:20 PST Rated: |
This Microsoft Knowledge Base article includes an example of doing this by accessing the Default Contacts folder: http://support.microsoft.com/default.aspx?scid=kb;en-us;181202 ---------------------------- Here is an example posted to a newsgroup: Dim olApp As New Application Dim MsgDataStore As NameSpace Dim MsgPersonalFolders As Folders Dim MsgContactFolder As MAPIFolder Dim itm As ContactItem Dim str As String Set MsgDataStore = olApp.GetNamespace("MAPI") Set MsgPersonalFolders = MsgDataStore.Folders("Personal Folders").Folders Set MsgContactFolder = MsgPersonalFolders("Contacts") For Each itm In MsgContactFolder.Items str = "" str = str & itm.FirstName & vbCrLf str = str & itm.LastName & vbCrLf str = str & itm.Email1Address & vbCrLf str = str & itm.HomeAddressCity & vbCrLf str = str & itm.HomeAddressState & vbCrLf Next itm There are other examples, but this one seems clearest. As you can see, you are right about accessing the Contacts folder. Google Groups Search Terms: Outlook VB HomeAddressCity ---------------------- This page has an interesting set of code samples for working with Outlook: http://www.helenfeddema.com/CodeSamples.htm#Code40 Here is a article showing some advanced techniques for working with the Outlook Object Model: http://www.fawcette.com/vsm/2002_09/magazine/columns/gettingstarted/default.asp Good luck with your project! - Hammer | |
|
whychild-ga
rated this answer:
Found an example, but I had to hack it to make it run. |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |