Home > Articles > Home & Office Computing

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Hacking Your Way Out of Outlook

Contrary to popular belief, most iPod owners use Windows computers, not Macs. This is important to remember, as we'll be messing around with Outlook.

In an earlier InformIT article, I explained that you can read contact information on your iPod if the info is stored as a vCard. The structure of a vCard is not easy to write:

BEGIN:VCARD 
VERSION:2.1 
N:Flash;Extending;; 
FN:Extending Flash 
EMAIL;PREF;INTERNET:Extendflash@flashguru.co.uk 
REV:20040530T174351 
UID:00000000190645CBE234E84DBBB4D5CBC448D3CC24F76800 
END:VCARD

Not very pretty.

The problem arises when you have a lot of vCards. How can you possibly write the correct code for all those vCards? If you're running Outlook 2000, XP, or 2003, the answer comes from a built-in feature. Most Microsoft Office users don't know that you can program Office applications with Visual Basic for Applications (VBA). We'll create a simple application to export all your contacts from Outlook to your iPod.

TIP

This is a great introduction to the world of VB programming, as you don't need to add a lot of code to get something that you can really use.

Follow these steps:

  1. Connect your iPod to your PC.

  2. In My Computer, find your iPod (it should appear as an additional hard drive). Double-click the iPod icon and find the folder called Contacts. The path will be something like H:\Contacts. This is where you'll place your contact information.

  3. Open Microsoft Outlook.

  4. To access the Visual Basic Development environment, press Alt+F11. This action opens the VBA editor.

  5. Choose, Insert, Module from the menu. Then add the following code:

    Const XPortPath As String = "H:\Contacts\" 'target location on your iPod 
    Const ext As String = ".vcf" 'file extension needed for iPod to read the vCard 
    
    Sub ExportToVCard() 
    Dim ns As NameSpace 
    Dim fld As MAPIFolder 
    Dim itm 
    Dim itms As Items 
    Set ns = Application.GetNamespace("MAPI") 
    Set fld = ns.GetDefaultFolder(olFolderContacts) 'Outlook Contacts folder 
    Set itms = fld.Items 
    itms.Sort "[LastName]", False 
    ' The following code is the loop that builds your code 
    For Each itm In itms 
    If TypeName(itm) = "ContactItem" Then 
    itm.SaveAs XPortPath & itm.LastNameAndFirstName & ext, olVCard 
    End If 
    Next itm 
    
    End Sub
  6. Press F5 to run the script, which places a list of all your contacts—in vCard format—in the Contacts folder on your iPod.

And just that easy, you can read all of your Outlook contacts on your iPod.

  • + Share This
  • 🔖 Save To Your Account