populating fields with information from the address book



We currently have 2 room setup forms, which are stored in public folders. The
forms have room & meeting information ,primary and secondary contact
information, and date and time information. All of the information is
manually entered , except for the requestor's name, division and employee
which is filled in automatically when the form is opened up. I oriiginally
edited the form with the script editor, but now when a new user opens the
form it only fills in the employee name, except when I open the form it works

In a previoius question, Sue referenced using CDO 1.21, but I don't know
what that means. She also mentioned "commenting out the On Error resume Next
statement" to help troubleshoot the issue. I am not sure what that means as
I am no programmer but am trying to resolve this OL issue. These are forms
that have been at our organization for awhile but the programmers are no
longer here and I could not find any documentation. Here is the code I think
references that functionality. Any guidance would be greatly appreciated.

'* Room set up script
'* this posts to a folder, has two click buttons which will cause messages
to be generaged
'* global settings
dim composemode
dim olemsession

'* ItemRead
'* This event will only occur when an item is loaded from storage
'* thus if a new item, then composemode set in global settings remains true

Sub Item_Read()
' if this subroutine occurs, then an item was read
Composemode = False
End Sub

'* Function: Item_Open()
'* Description: On composing the form, a MAPI Session
'* logs on and calls Sub GetDefaultFields()
'* to retrieve the user's name, department
'* and phone number.
Function Item_Open()
if item.size = 0 then 'if in compose mode

Set Item.userproperties("ContactPerson").value =

' get ole/message session object
Set olemsession = application.CreateObject("MAPI.Session")

' logon to current session
returncode =
olemsession.Logon(application.GetNameSpace("MAPI").CurrentUser, "", False,
False, 0)

Set mypage = Item.GetInspector.ModifiedFormPages("Meeting")

Call SetDefaultFields

'Logoff the session object

end if

End Function

'* PROCEDURE: SetDefaultFields
'* DESCRIPTION: Populate employee fields on the form with information
'* retrieved about the user from the address book.
Sub SetDefaultFields()
On Error Resume Next

Set user = olemsession.CurrentUser

item.userproperties.find("ContactPerson") = user.Name

item.userproperties.find("Division") = user.Fields.item(&h3a18001e)

item.userproperties.find("ContactPhone") = user.Fields.item(&h3a08001e)

end sub

Sue Mosher [MVP]

CDO 1.21 is a programming interface used when your code calls
CreateObject("MAPI.Session"). It is not installed with Outlook 2007 and must
be downloaded from
and installed separately on each Outlook 2007 machine that needs it. If you
have an earlier version of Outlook, CDO can be installed as an optional
Outlook component from the Office setup/maintenance program.

To comment out a line of code means to put an apostrophe at the beginning of
the line, telling Outlook not to run that code statement. If you look at
your code, you'll see that many statements are such comments.


Thanks Sue. I downloaded a CDO for a separate MS issue last May. I still
have it on a jump drive, however it does not show up in add/remove programs.
How can I tell if other PCs have the CDO?

My only confusion stems from the fact that this form seemed to work
correctly, prior to me editing some code. At least I never heard any
complaints from others if it did not. We have had OL 2007 and exchange 2007
for awhile now, if the CO was a possible issue why would it show up now?

Sue Mosher [MVP]

I have no idea what you mean by "a CDO." Microsoft unfortunately has used
the name "CDO" for several different things over the years. What you need
for Outlook 2007 code is the CDO 1.21 download at the URL I gave. Running
the .msi file in the download installs and registers the cdo.dll file.

Did you try commenting out the On Error Resume Next statement as I
suggested? That's going to give you the best picture of what errors may be
occurring as a result of the code that you've changed.
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators


, soThanks Sue,

last year while testing Vista and OL 07, we noticed that some of our older
custom forms did not work so someone had told me to download the current
version of the CDO to resolve the issue. I am not sure if it was 1.21, but
it seemed to resolve that issue. I downloaded CDO 1.21 from your link and
saved it over the previous version. I sent that to our tech support to test
and I believe they were going to push it out to all the user PCs via Altiris
once testing was completed. On the few outlook profiles they tested, ti
worked so thanks very much for your assistance. I have not commented out the
on error resume statements yet, as I wanted to see if the CDO 1.21 would
resolve the issue first.

On a different note, I know you write a lot of books regarding outlook and I
was wondering if your books were geared more towards programmers or wannabes
like me. Although no programmer (obviously), I would be interested in
learning more about Outlook & how the forms work. It would be nice to know if
there were other, or possibly better, ways we could benefit from Outlook.

Thanks so much for your assistance with this.

Sue Mosher [MVP]

My books were written with the beginner to intermediate Outlook programmer
in mind. Thanks for asking!

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