How to access user defined fields through VBA
Rod Plastow schrieb:
Hi Oliver,
I believe you will find your user defined fields/attributes in the
UserProperties collection for each particular item. Use the Find method to
set a reference to a particular UserProperty and then you can interrogate all
the object properties of that UserProperty. Here's a code extract from one
of my modules.
Public Sub InitialiseContact(p_Contact As Outlook.ContactItem)
Dim objProperty As Outlook.UserProperty
Dim objCategory As BEWarden.Category
Dim strCategory As String
Dim i As Integer
m_strFullName = p_Contact.FullName
m_strFileAs = p_Contact.FileAs
Set objProperty = p_Contact.UserProperties.Find("Salutation")
If (objProperty Is Nothing) Then
m_strSalutation = "Dear " & p_Contact.FirstName & "," & bewCrLf2
Else
m_strSalutation = "Dear " & objProperty.Value & "," & bewCrLf2
End If
Set objProperty = p_Contact.UserProperties.Find("Spouse First Name")
If Not (objProperty Is Nothing) Then
m_strSpouseFirstName = objProperty.Value
End If
Set objProperty = p_Contact.UserProperties.Find("Number Of Dependents")
If (objProperty Is Nothing) Then
m_intNumberDependents = 0
Else
m_intNumberDependents = objProperty.Value
End If
Hope this helps. (Incidentally I have long used Access as the engine on a
number of applications linking Access to an ERP via ODBC and then presenting
the analysis via Excel, Word, Project, Outlook etc. magic isn't it?)
Regards,
Rod
Hi Rod,
haven't tried it yet, but yes, it looks just like what I was trying to
do. Thanks a lot for your help, I'll be in the office on Tuesday and
will publish if it works.
Btw, I think you're right about 'magic':-) I think Microsoft's
developers must sometimes be really frustrated about how few people know
what great things you can do with their products.
|