The error I'm getting after I click Print is:
Object Required: 'Item.UserProperties.find(...)'
Usually doesn't that mean I need to set an item?
Two objects are involved in that statement -- Item and the UserProperty
object returned by UserProperties.Find. If this is code running in an
Outlook form, then Item is always valid, because it's the intrinsic object
representing the current item.
That leaves UserProperty. It's actually preferable not to use the Find
method and just use:
Item.UserProperties(strField)
If there is no custom property named with the name contained in the variable
strField, however, you will get an error when you try to use that property.
To test whether the property exists in the item, you can set a UserProperty
object and check it with an If ... Then ... End If block:
On Error Resume Next
Set objProp = Item.UserProperties(strField)
If Not objProp Is Nothing Then
strField1 = objprop.value
Else
MsgBox "No field named " & strField & _
" exists in this item."
End If
I'm really clueless as to what these methods and properties mean.
When in doubt, check the object browser: Press ALt+F11 to open the VBA
environment in Outlook, then press F2. Switch from <All Libraries> to
Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.
So it's hard for me to attempt to read the code and determine the problems
myself.
If that's the case, then you need to slow down, break the code out into
pieces, and take the time to understand its logic -- what it is actually
trying to accomplish -- rather than just copying and pasting and modifying
what may not have been a very good sample in the first place.
What are strField and strField1?
These are variables in your code but it's very confusing as to which is
related to the bookmark and which to the Outlook property. I'd give them
more descriptive names.
And I don't understand the If/Then statement.
What don't you understand about it? The logic of how an If ... Then ... End
If block works? The expression in the If ... Then statement?