Can't Get UserProperties To Work on Custom Form

J

John Lane

Please see the code snippet below. I have tried the three variations of
UserProperties and it always comes up with "Object variable or With variable
not set". Could someone adivse on what the proper syntax is? Thanks.

Set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
Set curInbox = olMAPI.GetDefaultFolder(olFolderInbox)

For itmcnt = 1 To curInbox.Items.Count
strMessageClass = curInbox.Items(itmcnt).MessageClass
If strMessageClass = "IPM.Note" Then
Set oMailItem = curInbox.Items(itmcnt)
If oMailItem.subject = "TEST1" Then
MsgBox "Subject = " & oMailItem.subject
'strText = oMailItem.UserProperties.Find("TextBox1").Value
'strText = oMailItem.UserProperties("TextBox1").Value
Set myTextBox = oMailItem.UserProperties("TextBox1")
MsgBox "myTextBox Object = " & myTextBox
strText = myTextBox.Value
MsgBox "TextBox1 = " & strText
End If
End If
Next
 
J

John Lane

Never mind. I'm stupid. I used the wrong Find value. So you have to use the
name of the custom field in the user defined field list, not the name it
acquires when it is placed on the form.
 
S

Sue Mosher [MVP-Outlook]

Huh? The custom field's name never, ever changes after you create it. Maybe you're mixing up the field name with the name of the control that displays it. They are two distinct objects; see http://www.outlookcode.com/d/propsyntax.htm.

FYI, there is a newsgroup specifically for Outlook forms issues "down the hall" at microsoft.public.outlook.program_forms or, via web interface, at http://www.microsoft.com/office/com...spx?dg=microsoft.public.outlook.program_forms

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top