Insert custom field in Outlook Contact List through VBA

I can add a custom field to the Field Chooser:
Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts).Folders("Test")
objContactsFolder.UserDefinedProperties.Add "Testing", olYesNo

How do I insert it into the contact folder heading (field) with VBA?
LVL 28
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, peakpeak.

I'm not clear on the question.  Are you asking how to modify the view so it shows this field?  If so, what version of Outlook are you using?
peakpeakAuthor Commented:
Yes, instead of opening the Field Chooser and drag the field in question to the headers and drop it where convenient I like to do that in VBA, OL 2007
David LeeCommented:
Assuming that you know the name of the field and that you want to add it to the current view, then this will do it.
Sub AddFieldToView()
    Dim olkView As Outlook.View
    Set olkView = Application.ActiveExplorer.CurrentView
    With olkView
        'On the next line edit the name of the field you want to add'
        .ViewFields.Add "Some_Field_Name"
    End With
    Set olkView = Nothing
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

peakpeakAuthor Commented:
Encountered some errors but essentially it worked. Thank You BlueDevilFan. You're the man !
David LeeCommented:
Thanks and you're welcome.  Always happy to help out.
peakpeakAuthor Commented:
Works like a charm now ... great brain BDF ....
David LeeCommented:
Thanks!  You're too kind.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.