Phone Message - Custom

G

Guest

The "object variable not set" comes up when you send the form with the script
running in the background. All of the sudden the debugger comes up and
states that the
strBody1 = strbody1 & Item.UserProperties("Caller") &
Item.UserProperties("Companytext") & Item.UserProperties("Phonetext")
"object variable not set." Then goes into the script debugger so you can
step into the problem and try and resolve it.
 
S

Sue Mosher [MVP-Outlook]

The statement with the problem:

strBody1 = strbody1 & Item.UserProperties("Caller") & Item.UserProperties("Companytext") & Item.UserProperties("Phonetext")

has 3 different objects in it, all Item.UserProperties("<propname>". The error indicates that one or more of these properties does not exist on the current item. There are two main reasons for that error:

1) You typed the wrong property name into the code.

2) You didn't add the property to the form design in such a way that it becomes part of the form design (and thus part of any created with the form) *and* the user has not entered any data into the corresponding text box that is bound to the property.

Both of these can be solved, you'll be happy to know, by opening the form in design mode.

The first thing to do is to check the property names. To do this, right-click on each text box control, switch to the Value tab, and get the field name from the top of that tab. The name of the control is irrelevant. All that matters here is the bound field name.

Once you do that, switch to the All Fields page of your form, and bring up the "User-defined fields in this item" list NOT the "User-defined fields in this folder" list. Do you see all your fields in that list? If not, go to any blank custom form page, bring up the Field Chooser, and drag the missing field(s) to the form page. Go back to All Fields and check that they're now on the list. You should be able to delete the fields from that custom page now and hide it. After you do, check back on All Fields one more time to make sure the fields are there. (You can read more about best practices for adding custom fields to forms at http://www.outlookcode.com/d/fields.htm)

Now, to make it easier to diagnose any problems if they remain, break up your code so that you have only one object per statement:

strBody1 = strbody1 & Item.UserProperties("Caller")
strBody1 = strBody1 & Item.UserProperties("Companytext")
strBody1 = strBody1 & Item.UserProperties("Phonetext")

Run it, and let us know how it goes.

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