Contacts.Company

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
 
S

Sue Mosher [MVP]

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
 

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

Top