<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How can create a simple program to modify Windows Address Book and Outlook Address Book entries?</title>
	<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries/</link>
	<description>Comments on Ask MetaFilter post How can create a simple program to modify Windows Address Book and Outlook Address Book entries?</description>
	<pubDate>Wed, 13 Aug 2008 08:22:34 -0800</pubDate>
	<lastBuildDate>Wed, 13 Aug 2008 08:22:34 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How can create a simple program to modify Windows Address Book and Outlook Address Book entries?</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries</link>	
		<description>I&apos;d like to create a simple program that would modify the phone numbers in my MS Windows and MS Outlook Address Books (reason is we got new area codes). What is the simplest programming language on windows and best way to get this done by directly accessing the address books (without exporting to CSV)? &lt;br /&gt;&lt;br /&gt; I&apos;ve done some VBS with WMI, Windows batch scripting, perl, python, javascript, PHP.. so I understand programming but not programming with MS Windows DLLs and COMs and APIs etc.&lt;br&gt;
&lt;br&gt;
I&apos;ve done some searching and found it quite complicated to work with VC++ or a similar language on MS Windows so far. Any input would be much appreciated. Thank you very much in advance.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.99079</guid>
		<pubDate>Wed, 13 Aug 2008 07:53:09 -0800</pubDate>
		<dc:creator>mrbloo</dc:creator>
		
			<category>windowsaddressbook</category>
		
			<category>microsoftoutlook</category>
		
			<category>programminglanguage</category>
		
			<category>programming</category>
		
			<category>microsoft</category>
		
			<category>windows</category>
		
	</item> <item>
		<title>By: fusinski</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442092</link>	
		<description>Visual Basic for Applications is your best bet.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://outlookcode.com/article.aspx?id=49&quot;&gt;Here&apos;s a good article&lt;/a&gt; on how to get started with Outlook VBA.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442092</guid>
		<pubDate>Wed, 13 Aug 2008 08:22:34 -0800</pubDate>
		<dc:creator>fusinski</dc:creator>
	</item><item>
		<title>By: SuperSquirrel</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442150</link>	
		<description>Visual Basic. You don&apos;t need to access dlls for this.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442150</guid>
		<pubDate>Wed, 13 Aug 2008 08:45:20 -0800</pubDate>
		<dc:creator>SuperSquirrel</dc:creator>
	</item><item>
		<title>By: unixrat</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442166</link>	
		<description>&lt;a href=&quot;http://www.tech-archive.net/Archive/Office/microsoft.public.office.developer.outlook.vba/2008-04/msg00036.html&quot;&gt;Here&apos;s a good start using VBA&lt;/a&gt;.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442166</guid>
		<pubDate>Wed, 13 Aug 2008 08:55:23 -0800</pubDate>
		<dc:creator>unixrat</dc:creator>
	</item><item>
		<title>By: blue_wardrobe</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442434</link>	
		<description>I know you said &quot;without exporting to CSV&quot;, but if you bring it into Excel through CSV, you just do a global replace of the affected area code, and then import it in again.&lt;br&gt;
&lt;br&gt;
Otherwise VBA. Something like this untested macro. Do not use without saving your contacts into another contacts backup folder!&lt;br&gt;
&lt;br&gt;
Sub Clean_Contacts()&lt;br&gt;
    Dim myContacts As Outlook.MAPIFolder&lt;br&gt;
    Dim myContactItems As Outlook.Items&lt;br&gt;
    Dim currentContact As Outlook.ContactItem&lt;br&gt;
    &lt;br&gt;
    Dim BadAreaCode As String&lt;br&gt;
    Dim NewAreaCode As String&lt;br&gt;
    &lt;br&gt;
    Dim Dirty As Boolean&lt;br&gt;
    &lt;br&gt;
    Dim p As Integer&lt;br&gt;
    &lt;br&gt;
    Const OldNum = &quot;(321)&quot;&lt;br&gt;
    Const NewNum = &quot;(456)&quot;&lt;br&gt;
    &lt;br&gt;
    Set myContacts = Application.GetNamespace(&quot;MAPI&quot;).GetDefaultFolder(olFolderContacts)&lt;br&gt;
    &lt;br&gt;
    Set myContactItems = myContacts.Items&lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &apos;&lt;br&gt;
    &apos; This code assumes all entries are contacts (no distribution lists)&lt;br&gt;
    &apos;&lt;br&gt;
    For Each currentContact In myContactItems&lt;br&gt;
    &lt;br&gt;
        Dirty = False&lt;br&gt;
        p = InStr(currentContact.HomeTelephoneNumber &amp;amp; &quot; &quot;, OldNum)&lt;br&gt;
        If p &amp;gt; 0 Then&lt;br&gt;
            &lt;br&gt;
            &apos; Found (321) in tel number at position p&lt;br&gt;
            If p &amp;gt; 1 Then&lt;br&gt;
                currentContact.HomeTelephoneNumber = Left(currentContact.HomeTelephoneNumber, p - 1) &amp;amp; NewNum &amp;amp; Mid(currentContact.HomeTelephoneNumber, p + Len(OldNum))&lt;br&gt;
            Else&lt;br&gt;
                currentContact.HomeTelephoneNumber = NewNum &amp;amp; NewNum &amp;amp; Mid(currentContact.HomeTelephoneNumber, p + Len(OldNum))&lt;br&gt;
            End If&lt;br&gt;
            &lt;br&gt;
            &apos; Add a category so you can find the banjaxed items if it goes wrong.&lt;br&gt;
            currentContact.Categories = currentContact.Categories &amp;amp; &quot;,ex-&quot; &amp;amp; OldNum&lt;br&gt;
            &lt;br&gt;
            Dirty = True&lt;br&gt;
            &lt;br&gt;
        End If&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
        &apos; You might have more conditional logic here. Set Dirty to True if you change the values&lt;br&gt;
        &lt;br&gt;
        If Dirty Then currentContact.Save&lt;br&gt;
            &lt;br&gt;
    Next&lt;br&gt;
    &lt;br&gt;
End Sub</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442434</guid>
		<pubDate>Wed, 13 Aug 2008 13:01:00 -0800</pubDate>
		<dc:creator>blue_wardrobe</dc:creator>
	</item><item>
		<title>By: blue_wardrobe</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442437</link>	
		<description>Sorry about the lost indentation.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442437</guid>
		<pubDate>Wed, 13 Aug 2008 13:01:30 -0800</pubDate>
		<dc:creator>blue_wardrobe</dc:creator>
	</item><item>
		<title>By: blue_wardrobe</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1442445</link>	
		<description>Bother - spotted an error already.&lt;br&gt;
&lt;br&gt;
Instead of:&lt;br&gt;
&lt;br&gt;
currentContact.HomeTelephoneNumber = NewNum &amp;amp; NewNum &amp;amp; Mid(currentContact.HomeTelephoneNumber, p + Len(OldNum))&lt;br&gt;
&lt;br&gt;
it should be:&lt;br&gt;
&lt;br&gt;
currentContact.HomeTelephoneNumber = NewNum &amp;amp; Mid(currentContact.HomeTelephoneNumber, p + Len(OldNum))</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1442445</guid>
		<pubDate>Wed, 13 Aug 2008 13:03:01 -0800</pubDate>
		<dc:creator>blue_wardrobe</dc:creator>
	</item><item>
		<title>By: mrbloo</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1445183</link>	
		<description>Thanks a lot for those! :)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1445183</guid>
		<pubDate>Fri, 15 Aug 2008 23:09:28 -0800</pubDate>
		<dc:creator>mrbloo</dc:creator>
	</item><item>
		<title>By: mrbloo</title>
		<link>http://ask.metafilter.com/99079/How-can-create-a-simple-program-to-modify-Windows-Address-Book-and-Outlook-Address-Book-entries#1445311</link>	
		<description>@blue_wardrobe - There were a few errors there, but I fixed them and thanks for that :) It works with Microsoft Outlook.&lt;br&gt;
&lt;br&gt;
I also found how to interface with the Windows Address Book (Address book used in Outlook Express) using the open source, free COM located at &lt;a href=&quot;http://wabaccess.sourceforge.net/&quot;&gt;http://wabaccess.sourceforge.net/&lt;/a&gt; it does exactly what I wanted perfectly! &lt;br&gt;
&lt;br&gt;
I just might post a link to the code of the application I with this to help out those who fall upon this page on their searches.&lt;br&gt;
&lt;br&gt;
Thanks all once again.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.99079-1445311</guid>
		<pubDate>Sat, 16 Aug 2008 06:05:03 -0800</pubDate>
		<dc:creator>mrbloo</dc:creator>
	</item>
	</channel>
</rss>
