A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Can't Get UserProperties To Work on Custom Form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 23rd 07, 07:44 PM posted to microsoft.public.outlook.program_vba
John Lane
external usenet poster
 
Posts: 26
Default Can't Get UserProperties To Work on Custom Form

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
Ads
  #2  
Old March 23rd 07, 07:57 PM posted to microsoft.public.outlook.program_vba
John Lane
external usenet poster
 
Posts: 26
Default Can't Get UserProperties To Work on Custom Form

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.

"John Lane" wrote:

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

  #3  
Old March 23rd 07, 08:29 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Can't Get UserProperties To Work on Custom Form

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/comm...rogram_f orms

--
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

"John Lane" wrote in message ...
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.

"John Lane" wrote:

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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
importing custom fields into a custom form susan lasalle Outlook - Using Contacts 1 January 16th 07 10:01 PM
Custom Form - Receiver replies and form is gone, message body is b Kozlik Outlook - Using Forms 16 July 14th 06 10:32 PM
Emailing a contact vCard with custom form loses all custom info Kim Outlook - Using Contacts 7 April 27th 06 01:21 AM
How to access custom field in Custom Form by C# Minh Nguyen Outlook - Using Forms 3 April 24th 06 04:32 PM
Cannot programmatically open custom message in custom form ms Outlook - Using Forms 1 January 20th 06 04:01 PM


All times are GMT +1. The time now is 08:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.