I am trying to build a routing that will process an aray of property names and obtain the property values from an object. If you examine the following code, the routine "BuildString_One" creates a string based on the propery values. I am trying to build the same string in the second routine, "BuildString_Two", using an array of property names instead. How do I evaluate the property names in the array to the underlying property values?
Code:
Private aFields(5) As String
Sub BuildList()
aFields(0) = “.FullName”
aFields(1) = “.BusinessAddress”
aFields(2) = “.BusinessAddressStreet”
aFields(3) = “.BusinessAddressCity”
aFields(4) = “.BusinessAddressState”
aFields(5) = “.BusinessAddressPostalCode”
Dim oOutlook As Outlook.NameSpace
Dim oFolder As Outlook.Folder
Dim oContactItem As Object
Dim oContact As ContactItem
Set oOutlook = Application.Session
Set oFolder = oOutlook.GetDefaultFolder(olFolderContacts)
For Each oContactItem In oFolder.Items
If (oContactItem.Class = olContact) Then
Set oContact = oContactItem
BuildString_One oContact
BuildString_Two oContact
End If
Next
End Sub
Sub BuildString_One(oContact As ContactItem)
Dim cString As String
With oContact
cString = .FullName & Chr(9) _
& .BusinessAddress & Chr(9) _
& .BusinessAddressStreet & Chr(9) _
& .BusinessAddressCity & Chr(9) _
& .BusinessAddressState & Chr(9) _
& .BusinessAddressPostalCode
End With
End Sub
Sub BuildString_Two(oContact As ContactItem)
Dim iIndex As Integer
Dim cString As String
With oContact
For iIndex = 0 To UBound(aFields)
' The following is the line needing the help................
[COLOR=#EF2929]cString = Cstring + (.Afields(iIndex)) & Chr(9)[/color]
Next
End With
End Sub