Re: Sorting tasks by calculated field - automatically update task-
I guess it should run in "ThisOutlookSession" - I don't have a special form.
It's basically just a custom field I add to the Tasks to create a column I
can use to sort my tasks. But the column I have added is made as a "formula"
field that Outlook won't use for sorting for some reason. It is however
possible to add another custom Integer field that Outlook can use for
sorting. So everytime a task is updated I want to copy the value of the
calculated field to this custom Integer field.
I did find some sample code in another thread that I think can be a starting
point:
Dim WithEvents myInspectors As Inspectors
Dim WithEvents myTaskItem As TaskItem
Private Sub Application_Startup()
Set myInspectors = Outlook.Inspectors ' Here I get a "Syntax error"!
End Sub
Private Sub myInspectors_NewInspector(ByVal Inspector As Inspector)
If TypeName(Inspector.CurrentItem) = "TaskItem" Then
Set myTaskItem = Inspector.CurrentItem
End If
End Sub
Private Sub myTaskItem_Close(Cancel As Boolean)
Set myTaskItem = Nothing
End Sub
Private Sub myTaskItem_PropertyChange(ByVal Name As String)
If Name = "Status" Then
If myTaskItem.Complete = True Then
MsgBox "Task " & myTaskItem.Subject & " now completed"
End If
End If
End Sub
> ... And then change to content of the _ProportyChange Sub to copy the value.
BUT adding this in ThisOutlookSession gives me a "Syntax error" in the "Set"
line of the application_Startup() sub. I can replace it with a MsgBox that
works.
Actually all content within the "Sub's" are colored red.
It's Outlook 2007. I have no prior experience with VBA coding, so any help
will be appriciated.
wrote:
> Where is this code running, is this form code or Outlook VBA macro code or a
> COM addin or ...?
> It sounds like form code, in which case your best bet is to go to
> www.outlookcode.com and look there in the Forms information, especially in
> the sections about bound controls and control and property syntax.
> >
>
> "BMunk" <BMunk> wrote in message
> news:733BCF50-A023-4B01-AB64-441FAB7A2457@microsoft.com...
> > Thanks a lot for the quick reply!
> > I have never programmed in Outlook before (Outlook 2007), so could you
> > give
> > me a quick hint/reference to sample code for setting a custom task field
> > value to the value of another custom formula field when one of the custom
> > formula field of a task changes?
> > I would appriciate a lot - thanks!
>