Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
 

This will export a custom keyword field into an Excel spreadsheet.

Private Sub cmdExportContacts_Click()
'Goto Contacts Folder

Dim oOLapp As Outlook.Application
Dim oSalesFldrs As Outlook.MAPIFolder

Dim oXLapp As Excel.Application
Dim oXLBook As Excel.Workbook

Dim i As Integer
Dim iRow As Integer
Dim j As Integer


Set oOLapp = GetObject(, "Outlook.Application")
Set oSalesFldrs = oOLapp.GetNamespace("MAPI").Folders("Sales
Folders").Folders("Sales Contacts")

Set oXLapp = CreateObject("Excel.Application")
oXLapp.Visible = True
Set oXLBook = oXLapp.Workbooks.Add()

' For Each Item In oSalesFldrs
iRow = 0
For i = 1 To oSalesFldrs.Items.Count
With oSalesFldrs.Items(i)
iRow = i + 1
j = 1
oXLBook.Sheets(1).Cells(iRow, j) = .FirstName
j = j + 1
oXLBook.Sheets(1).Cells(iRow, j) = .LastName
j = j + 1
oXLBook.Sheets(1).Cells(iRow, j) = .BusinessAddress
j = j + 1
oXLBook.Sheets(1).Cells(iRow, j) =
fcPropToStr(.UserProperties.Find("Account Executive").Value)
j = j + 1
oXLBook.Sheets(1).Cells(iRow, j) =
fcPropToStr(.UserProperties.Find("Custom Category").Value)
End With
Next i
End Sub

Private Function fcPropToStr(varProp As Variant) As String
Dim cOutStr As String
Dim i As Integer
Dim cDelim As String

cDelim = ";"
If IsArray(varProp) Then
i = LBound(varProp)
While (i <= UBound(varProp))
If (i = LBound(varProp)) Then
cOutStr = CStr(varProp(i))
Else
cOutStr = cOutStr & cDelim & CStr(varProp(i))
End If
i = i + 1
Wend
Else
cOutStr = CStr(varProp)
End If

fcPropToStr = cOutStr
End Function


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006