Custom Contact form with client's photo

G

Graeme

I'm trying to customise a contact form and add in the client's photo. I tried
the instructions on http://www.outlookcode.com/article.aspx?id=33 but got
stuck trying to use a naming convention to link each contact with a different
picture.

Here's the code they give:

Function Item_Open()
Set objInsp = Item.GetInspector
Set objPage = objInsp.ModifiedFormPages("Picture")
Set imgPicture = objPage.Controls("imgPicture")
If Item.BillingInformation <> "" Then
imgPicture.Picture = _
LoadPicture(Item.BillingInformation)
End If
End Function

I made an image control called 'imgPicture', then stored the pictures in the
field "User Defined 4" and then changing the code to

Function Item_Open()
Set objInsp = Item.GetInspector
Set objPage = objInsp.ModifiedFormPages("Picture")
Set imgPicture = objPage.Controls("imgPicture")
If Item.BillingInformation <> "" Then
imgPicture.Picture = _
LoadPicture(Item.UserDefined4)
End If
End Function

I was feeling very clever and expected to open the contact form and see the
picture. However Outlook didn't like my code, wanted me to debug, and all
sorts of scary stuff.

What did I do wrong?

Graeme
 
S

Sue Mosher [MVP-Outlook]

Item.UserDefined4 is invalid syntax for a custom field. See
http://www.outlookcode.com/article.aspx?ID=38

Or are you referring to the standard ContactItem.User4 field? Remember that
you can use the object browser (F2 in VBA) to look up the exact names of
Outlook properties.

If you're going to change the code to use a field other of the standard
BillingInformation field that's used in the original sample, then you need to
make that change in both places. Otherwise, the LoadPicture statement will
never execute.

If you get an error, please post details. We can't read your mind or look
over your shoulder.
 
G

Graeme

Thankyou Sue, that is very helpful and now it is working. Next question: how
do I resize the image to fit in the box? at the moment I can only see a small
part of the top left hand corner.

I did check Properties and Advanced Properties. I found one called 'resize'
but it changed the size of the box, not the image!

Graeme
 

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

Similar Threads


Top