ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel reading user defined fields in Outlook (https://www.excelbanter.com/excel-programming/273982-excel-reading-user-defined-fields-outlook.html)

Richard Naish

Excel reading user defined fields in Outlook
 
Hi,

I cannot seem to be able to access/dispay the content of a user defined
field on an Outlook contact form from within Excel VBA.

Any thoughts very much appreciated! Here is the code:

Sub Open_Outlook()
Dim MyProperty As Object
Dim MyFolder2 As Outlook.MAPIFolder
' Creates path to Outlook and to the Landlords Properties folder

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set MyFolder1 = olns.GetDefaultFolder(olFolderContacts)
Set MyFolder2 = MyFolder1.Folders("Properties")
Set MyProperties = MyFolder2.Items
Set MyProperty = MyProperties.Find("[FullName] = ""D101""")
If MyProperty Is Nothing Then ' Find failed
MsgBox "Property Reference not found"
Else
MsgBox MyProperty.FullName
MsgBox MyProperty.UserProperties("LLsurname") ' This is the problem!!
End If
End Sub





keepITcool

Excel reading user defined fields in Outlook
 

You can download my addin Outlook2Excel
from http://members.chello.nl/keepitcool/download.html


It's unprotected so you can review the code.
Heck you might even like it and use it :)

Note that you should swap the interface language by clicking
the "empty" button on the taskbar!


Be aware that outlook 9 and 10 are different with respect to the
userproperties. (Review Object Explorer/and or Help)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Richard Naish" wrote:

Hi,

I cannot seem to be able to access/dispay the content of a user

defined
field on an Outlook contact form from within Excel VBA.

Any thoughts very much appreciated! Here is the code:

Sub Open_Outlook()
Dim MyProperty As Object
Dim MyFolder2 As Outlook.MAPIFolder
' Creates path to Outlook and to the Landlords Properties folder

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set MyFolder1 = olns.GetDefaultFolder(olFolderContacts)
Set MyFolder2 = MyFolder1.Folders("Properties")
Set MyProperties = MyFolder2.Items
Set MyProperty = MyProperties.Find("[FullName] = ""D101""")
If MyProperty Is Nothing Then ' Find failed
MsgBox "Property Reference not found"
Else
MsgBox MyProperty.FullName
MsgBox MyProperty.UserProperties("LLsurname") ' This is the

problem!!
End If
End Sub








All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com