This is my first question here so bear with me. I have an Outlook/VBA issue that is driving me batty.
I have customized the Outlook Contact form and added a number of user defined fields and now I need to run a VBA routine to update 2 newly added custom fields.
Here's the relevant code:
Set objExpl = Application.ActiveExplorer
If Not objExpl Is Nothing Then
Set objSelection = objExpl.Selection
If objSelection.Count > 0 Then
For i = 1 To objSelection.Count
Set objItem = objSelection.item(i)
If Not objItem Is Nothing Then
If objItem.Class = olContact Then
objItem.UserProperties("EmployerIndustry").Value = txtIndustry.Text
The user defined field "EmployerIndustry" gets the value from the textbox. When this line is executed, a message box is thrown up: Script Error Object required: '' Line No:74
And when I check the error number it shows nbr 91.
However, if I change the user defined property to another one, say "Newsletter" there's no error. Yesterday I called this property "MajorCategory" and it kept throwing this error, so I changed the field name to "EmployerIndustry" and then it worked. Today the same error is showing up again.
After the messagebox is dismissed the code functions as it should and the value gets set in the user defined field. If I add a Quickwatch and check the values, everything looks as it should.
If I open a contact item and check User-defined fields in this item and in this folder, the field is there.
I have other VBA routines that do various updates to User-defined properties and they all run without errors with the same code. I have seen some people suggest that I declare and initialize the UserProperties collection and then add the property and assign that to a variable and finally set the value from the text box to this variable, tried that, same result.
Can you shed some light on this? Would really, really appreciate it.