Contacts.Company

  • Thread starter Thread starter Ross Culver
  • Start date Start date
R

Ross Culver

I have a combobox that I set the list value on when opening a Post form. Using the code below, I can set the list to equal contact fullname, but it errors out when I try to use the contact company field. Why?

Function Item_Open()
dim strUser, I, X, Y
Set myNameSpace = Application.GetNameSpace("MAPI")
set myItem = GetInspector.ModifiedFormPages("Account Checklist")
Set fldAcctMgr = myNameSpace.Folders("Personal Folders").Folders("Contacts")
Set itmAcctMgr = fldAcctMgr.Items
Set fltAcctMgr = itmAcctMgr.restrict("[JobTitle] = 'Account Manager'")
X = fltAcctMgr.Count
Redim amArray(X)
For I = 1 to X
amArray(I) = fltAcctMgr(I).FullName
Next
myItem.cboxAcctMgr.List = amArray
End Function

Thanks,

Ross
 
There is no ContactItem.Company property. When in doubt, check the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2. The property you're looking for is CompanyName.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers


I have a combobox that I set the list value on when opening a Post form. Using the code below, I can set the list to equal contact fullname, but it errors out when I try to use the contact company field. Why?

Function Item_Open()
dim strUser, I, X, Y
Set myNameSpace = Application.GetNameSpace("MAPI")
set myItem = GetInspector.ModifiedFormPages("Account Checklist")
Set fldAcctMgr = myNameSpace.Folders("Personal Folders").Folders("Contacts")
Set itmAcctMgr = fldAcctMgr.Items
Set fltAcctMgr = itmAcctMgr.restrict("[JobTitle] = 'Account Manager'")
X = fltAcctMgr.Count
Redim amArray(X)
For I = 1 to X
amArray(I) = fltAcctMgr(I).FullName
Next
myItem.cboxAcctMgr.List = amArray
End Function

Thanks,

Ross
 
Back
Top