Function GetPerson(Title, Caption, TxtCtrl, NameCtrl, MailCtrl)
  on error resume next

	Set ab = createobject("MsSvAbw.AddrBookWrapper")
  if err = 0 then
    ab.OneAddress = true
    ab.AddressBook cstr(Title), , cstr(Caption), , , ret, , , True
    sName = ret(1).FullName
    sAddress = ret(1).SMTPAddress
  else
    err.clear
    set O = getobject("", "Outlook.Application")
    if err <> 0 then
      msgbox "Error instantiating Outlook Address Book component.", vbCritical, "Error"
      exit Function
    end if

    Set N = O.GetNamespace("MAPI")
    Set S = N.GetSelectNamesDialog
    if err <> 0 then
      msgbox "Error instantiating Outlook Address Book component.", vbCritical, "Error"
      exit Function
    end if
   
    S.AllowMultipleSelection = False
    S.ToLabel = cstr(Caption)
    S.Caption = cstr(Title)
    S.NumberOfRecipientSelectors = olShowTo
    S.Display
    if s.Recipients.count > 0 then
      sName = s.Recipients.Item(1).Name
      sAddress = s.Recipients.Item(1).Address
    end if
  end if

	if len(trim(sName)) > 0 then
		TxtCtrl.value = sName & " (" & sAddress & ")"
		NameCtrl.value = sName
		MailCtrl.value = sAddress
	end if
End Function
