Problem with userproperty formulas

G

Guest

I am trying to create user-defined-fields in my contacts folder that have formulas programmatically. I'm having no issues with creating the fields themselves, but for some reason the formulas that I set are not there in Outlook. Here is a code snippet - can anyone help

Dim myolapp as new Outlook Applicatio
Dim StandardContact as Outlook.ContactIte
Dim ContactProperties as Outlook.UserPropertie
Dim FormulaField as Outlook.UserPropert

Set StandardContact = myOlApp.CreateItem(olContactItem
Set ContactProperties = StandardContact.UserPropertie
Set FormulaField = ContactProperties.Add("Formula Field", Outlook.OlUserPropertyType.olFormula
FormulaField.Formula = "DateDiff('d',Now(),[Test Date])
MsgBox "Formula Field value = " & FormulaField.valu

"Test Date" is another userproperty that is set up elsewhere in the code. The message box shows the correct value, but when the formula field shows up in the Field Chooser of the Contacts folder in the user-defined fields in folder section the formula is blank. Does anyone know what I am doing wrong

Thanks

rdw
 
S

Sue Mosher [MVP]

IIRC, you can't set formulas programmatically, even though it looks like you
should be able to from the object model.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


rebdewinter said:
I am trying to create user-defined-fields in my contacts folder that have
formulas programmatically. I'm having no issues with creating the fields
themselves, but for some reason the formulas that I set are not there in
Outlook. Here is a code snippet - can anyone help?
Dim myolapp as new Outlook Application
Dim StandardContact as Outlook.ContactItem
Dim ContactProperties as Outlook.UserProperties
Dim FormulaField as Outlook.UserProperty

Set StandardContact = myOlApp.CreateItem(olContactItem)
Set ContactProperties = StandardContact.UserProperties
Set FormulaField = ContactProperties.Add("Formula Field", Outlook.OlUserPropertyType.olFormula)
FormulaField.Formula = "DateDiff('d',Now(),[Test Date])"
MsgBox "Formula Field value = " & FormulaField.value

"Test Date" is another userproperty that is set up elsewhere in the code.
The message box shows the correct value, but when the formula field shows up
in the Field Chooser of the Contacts folder in the user-defined fields in
folder section the formula is blank. Does anyone know what I am doing
wrong?
 
G

Guest

Thanks for your response, Sue. Are there any work arounds that you know of like somehow copying the formula field from a view to the folder?
 
S

Sue Mosher [MVP]

Workaround for what? Your latest message is a little short on detail. Please
take the time to quote the original message so that people reading your
current response can understand what you're talking about. Otherwise, you
may not receive the answer you're looking for.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



rebdewinter said:
Thanks for your response, Sue. Are there any work arounds that you know
of like somehow copying the formula field from a view to the folder?
 
G

Guest

sorry about that, Sue, I thought prior messagees would be automatically be included. The original issue is that I was trying to programmatically set formulas for formula fields that I added to folders in Outlook. You sent me a reply letting me know that it is not possible to programmatically set formulas. I'm wondering if there is a work around so that I can get formula fields in Outlook folders automatically simiar to the work around for installing views in versions of Outlook prior to 2002 where you import a folder and copy a view - can I copy just fields some how? I have to find a way to get those formula fields in Outlook via an installation program that I have written in VB .Net. Any help you can give would be greatly appreciated

regards

RDW
 
S

Sue Mosher [MVP]

You would have to build the view manually and then copy the entire folder,
either manually or programmatically.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


rebdewinter said:
sorry about that, Sue, I thought prior messagees would be automatically be
included. The original issue is that I was trying to programmatically set
formulas for formula fields that I added to folders in Outlook. You sent me
a reply letting me know that it is not possible to programmatically set
formulas. I'm wondering if there is a work around so that I can get formula
fields in Outlook folders automatically simiar to the work around for
installing views in versions of Outlook prior to 2002 where you import a
folder and copy a view - can I copy just fields some how? I have to find a
way to get those formula fields in Outlook via an installation program that
I have written in VB .Net. Any help you can give would be greatly
appreciated.
 

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