Formula Property

Microsoft Outlook Visual Basic

Returns or sets a String representing the formula for the user property. Read/write.

expression.Formula

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

If a program tries to reference any type of recipient information by using the Outlook object model, a dialog box is displayed that asks you to confirm access to this information. You can allow access to the Address Book or recipient information for up to ten minutes after you receive the dialog box. This allows features, such as mobile device synchronization, to be completed.

You receive the confirmation dialog box when a solution tries to programmatically access the Formula property.

Example

The following Visual Basic for Applications (VBA) example shows how to use the Formula property.

Sub TestFormula()
    Dim outApp As New Outlook.Application
    Dim tki As Outlook.TaskItem
    Dim uprs As Outlook.UserProperties
    Dim upr As Outlook.UserProperty
    
    Set tki = outApp.CreateItem(olTaskItem)
    tki.Subject = "Work hours - Test Formula"
    tki.TotalWork = 4
    tki.ActualWork = 3
    Set uprs = tki.UserProperties
    Set upr = uprs.Add("Total&ActualWork", olFormula)
    upr.Formula = "[Total Work] + [Actual Work]"
    tki.Save
    
    tki.Display
   MsgBox "The Work Hours are: " & upr.Value
End Sub