PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Form Programming How to access user defined fields through VBA

Reply

How to access user defined fields through VBA

 
Thread Tools Rate Thread
Old 03-06-2006, 11:09 PM   #1
=?ISO-8859-15?Q?Oliver_Gr=E4ser?=
Guest
 
Posts: n/a
Default How to access user defined fields through VBA


Hi there,

I just started to customize Outlook 2000 a little, fascinating what this
program can do. I created a new form, extending an appointment with two
name fields and an additional begin/end time for each of these names.
What I intended to be the fun part was accessing the data in these
fields from Access. We use some VBA macros here to create tasks in a
public folder from data provided from our ERP database. Creating these
tasks works fine as I don't need any additional fields in these task,
and I know how to access all properties of TaskItem. However, I have no
idea how to access the data in the additional fields. I suppose the form
creates a class that inherites all properties of AppointmentItem. But
how is this class named, and its properties? Is it possible to access
those fields through VBA at all? Or does a later version of Exchange /
Outlook (we're using 2000) offer these features? Btw, if anyone knows
any book etc dealing with this, just give me a hint...

Thanks a lot

Oliver
  Reply With Quote
Old 04-06-2006, 10:26 AM   #2
=?Utf-8?B?Um9kIFBsYXN0b3c=?=
Guest
 
Posts: n/a
Default RE: How to access user defined fields through VBA

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

"Oliver Gräser" wrote:

> Hi there,
>
> I just started to customize Outlook 2000 a little, fascinating what this
> program can do. I created a new form, extending an appointment with two
> name fields and an additional begin/end time for each of these names.
> What I intended to be the fun part was accessing the data in these
> fields from Access. We use some VBA macros here to create tasks in a
> public folder from data provided from our ERP database. Creating these
> tasks works fine as I don't need any additional fields in these task,
> and I know how to access all properties of TaskItem. However, I have no
> idea how to access the data in the additional fields. I suppose the form
> creates a class that inherites all properties of AppointmentItem. But
> how is this class named, and its properties? Is it possible to access
> those fields through VBA at all? Or does a later version of Exchange /
> Outlook (we're using 2000) offer these features? Btw, if anyone knows
> any book etc dealing with this, just give me a hint...
>
> Thanks a lot
>
> Oliver
>

  Reply With Quote
Old 04-06-2006, 01:57 PM   #3
=?UTF-8?B?T2xpdmVyIEdyw6RzZXI=?=
Guest
 
Posts: n/a
Default Re: 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.
  Reply With Quote
Old 04-06-2006, 04:28 PM   #4
Hollis Paul [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: How to access user defined fields through VBA

In article <e5MFap1hGHA.4776@TK2MSFTNGP05.phx.gbl>, Oliver_Gräser wrote:
> Is it possible to access
> those fields through VBA at all? Or does a later version of Exchange /
> Outlook (we're using 2000) offer these features? Btw, if anyone knows
> any book etc dealing with this, just give me a hint...
>
> Thanks a lot
>

The primary resources for all things Outlook and Exchange are
www.outlookcode.com and www.slipstick.com

OutlookCode.com :: Microsoft Outlook Programming - Jumpstart for
Administrators, Developers, and Power Users
search c code and forums a articles login password Remember me You will
need to and log in if you want to download the source code for the
Microsoft Outlook Programming ...
http://www.outlookcode.com/jumpstart.aspx - 38 KB


Import and Exporting Data from Custom Microsoft Outlook Forms
5/15/2006
How to import or export data from custom Microsoft Outlook fields and
forms via Microsoft Access, Microsoft Excel and text files
http://www.outlookcode.com/d/customimport.htm - 23 KB

Import and Exporting Data from Custom Microsoft Outlook Forms
5/10/2006
How to import or export data from custom Microsoft Outlook fields and
forms via Microsoft Access, Microsoft Excel and text files
http://www.outlookcode.com/archive0/d/customimport.htm - 24 KB

Slipstick Systems Outlook and Exchange Utility Rating
Listing of new utilities and other resources for Microsoft Outlook and
Microsoft Exchange
http://www.slipstick.com/contest/listings.aspx - 29 KB


To set up subcategories 1/19/2006
How to use subcategories in Microsoft Outlook
http://www.slipstick.com/outlook/subcats.htm - 17 KB

Visual Basic and VBA Coding in Microsoft Outlook 5/10/2006
Resources for writing Visual Basic for Applications macros and Visual
Basic programs for Microsoft Outlook
http://www.outlookcode.com/d/vb.htm - 44 KB

--
Hollis Paul
Mukilteo, WA USA


  Reply With Quote
Old 07-06-2006, 10:31 PM   #5
=?UTF-8?B?T2xpdmVyIEdyw6RzZXI=?=
Guest
 
Posts: n/a
Default Re: How to access user defined fields through VBA

Hi Rod,

I tested it and it worked out fine, thanks a lot. However it lead me to
another problem: If I want to create an Item which is an instance of my
modified task, I use MAPIfolder.Items.Add("IPM.Task.MyTaskName"), that's
what my office help file told me to do. However, just an ordinary task
is created. I wondered if I have to pass the MessageClass as an Object,
but I don't know how to obtain that object - all I know is the String
representation. Do you have an idea?

Cheers,

Oliver


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
>
> "Oliver Gräser" wrote:
>
>> Hi there,
>>
>> I just started to customize Outlook 2000 a little, fascinating what this
>> program can do. I created a new form, extending an appointment with two
>> name fields and an additional begin/end time for each of these names.
>> What I intended to be the fun part was accessing the data in these
>> fields from Access. We use some VBA macros here to create tasks in a
>> public folder from data provided from our ERP database. Creating these
>> tasks works fine as I don't need any additional fields in these task,
>> and I know how to access all properties of TaskItem. However, I have no
>> idea how to access the data in the additional fields. I suppose the form
>> creates a class that inherites all properties of AppointmentItem. But
>> how is this class named, and its properties? Is it possible to access
>> those fields through VBA at all? Or does a later version of Exchange /
>> Outlook (we're using 2000) offer these features? Btw, if anyone knows
>> any book etc dealing with this, just give me a hint...
>>
>> Thanks a lot
>>
>> Oliver
>>

  Reply With Quote
Old 07-06-2006, 10:36 PM   #6
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: How to access user defined fields through VBA

Where is the MyTaskName form published? Show your complete code statement, please.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Oliver Gräser" <oliver.graeser@uni-konstanz.de> wrote in message news:OG2DAnniGHA.4572@TK2MSFTNGP05.phx.gbl...
> Hi Rod,
>
> I tested it and it worked out fine, thanks a lot. However it lead me to
> another problem: If I want to create an Item which is an instance of my
> modified task, I use MAPIfolder.Items.Add("IPM.Task.MyTaskName"), that's
> what my office help file told me to do. However, just an ordinary task
> is created. I wondered if I have to pass the MessageClass as an Object,
> but I don't know how to obtain that object - all I know is the String
> representation. Do you have an idea?
>
> Cheers,
>
> Oliver
>
>
> 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
>>
>> "Oliver Gräser" wrote:
>>
>>> Hi there,
>>>
>>> I just started to customize Outlook 2000 a little, fascinating what this
>>> program can do. I created a new form, extending an appointment with two
>>> name fields and an additional begin/end time for each of these names.
>>> What I intended to be the fun part was accessing the data in these
>>> fields from Access. We use some VBA macros here to create tasks in a
>>> public folder from data provided from our ERP database. Creating these
>>> tasks works fine as I don't need any additional fields in these task,
>>> and I know how to access all properties of TaskItem. However, I have no
>>> idea how to access the data in the additional fields. I suppose the form
>>> creates a class that inherites all properties of AppointmentItem. But
>>> how is this class named, and its properties? Is it possible to access
>>> those fields through VBA at all? Or does a later version of Exchange /
>>> Outlook (we're using 2000) offer these features? Btw, if anyone knows
>>> any book etc dealing with this, just give me a hint...
>>>
>>> Thanks a lot
>>>
>>> Oliver
>>>

  Reply With Quote
Old 08-06-2006, 03:15 PM   #7
=?UTF-8?B?T2xpdmVyIEdyw6RzZXI=?=
Guest
 
Posts: n/a
Default Re: How to access user defined fields through VBA

Sue Mosher [MVP-Outlook] schrieb:
> Where is the MyTaskName form published? Show your complete code statement, please.
>

Hi Sue,

many thanks for replying to this hidden message:-) I'm very sorry, it
turned out to be a typo in the MessageClass String, I hadn't expected
that Access would just ignore that the Argument referred to a
non-existing form.

Thanks a lot

Oliver
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off