Sorting tasks by calculated field - automatically update task-fiel

Status
Not open for further replies.
Q

Qk11bms

Hi,

I have a calculated field in Tasks that I would like to sort the tasks by,

but Outlook does not allow that.

Is it posible to make another Integer field (that can be sorted), and have

an event fire whenever a task item is updated so that I can assign the

content of the calculated field into the new integer field?

(Or any other work-around to sort by calculated field?)

Thanks!
 
If you want an event when the item is saved use the item.Write() method. If

you want it when a built-in property is changed use item.PropertyChange(),

for a user property being changed use item.CustomPropertyChange().

"BMunk" <BMunk> wrote in message

news:226B8061-61C0-4E8E-9814-909B5FB1087A@microsoft.com...
> Hi,
> I have a calculated field in Tasks that I would like to sort the tasks by,
> but Outlook does not allow that.
> Is it posible to make another Integer field (that can be sorted), and have
> an event fire whenever a task item is updated so that I can assign the
> content of the calculated field into the new integer field?
> (Or any other work-around to sort by calculated field?)

> Thanks!
>
 
Re: Sorting tasks by calculated field - automatically update task-

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!
wrote:


> If you want an event when the item is saved use the item.Write() method. If
> you want it when a built-in property is changed use item.PropertyChange(),
> for a user property being changed use item.CustomPropertyChange().

> >

>

> "BMunk" <BMunk> wrote in message
> news:226B8061-61C0-4E8E-9814-909B5FB1087A@microsoft.com...
> > Hi,
> > I have a calculated field in Tasks that I would like to sort the tasks by,
> > but Outlook does not allow that.
> > Is it posible to make another Integer field (that can be sorted), and have
> > an event fire whenever a task item is updated so that I can assign the
> > content of the calculated field into the new integer field?
> > (Or any other work-around to sort by calculated field?)
> > Thanks!
> >


>
 
Re: Sorting tasks by calculated field - automatically update task-

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!
 
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!


>
 
Re: Sorting tasks by calculated field - automatically update task-

Update:

I solved the "syntax" error. For some reason copy/paste made some invisible

"syntax" error! If I rewrote the text, all can compile :)

However, none of the other Sub's (exept the Startup) is ever executed when I

change a task status to anything (e.g completed). I check this with a MsgBox

in the beginning of all the sub's.

Any suggestions?

"BMunk" wrote:


> 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!

> >
 
Re: Sorting tasks by calculated field - automatically update task-

How can I get an event when any task in the task folder has any of it's

properties updated? (e.g. Status set to "Deferred")?
wrote:


> If you want an event when the item is saved use the item.Write() method. If
> you want it when a built-in property is changed use item.PropertyChange(),
> for a user property being changed use item.CustomPropertyChange().

> >

>

> "BMunk" <BMunk> wrote in message
> news:226B8061-61C0-4E8E-9814-909B5FB1087A@microsoft.com...
> > Hi,
> > I have a calculated field in Tasks that I would like to sort the tasks by,
> > but Outlook does not allow that.
> > Is it posible to make another Integer field (that can be sorted), and have
> > an event fire whenever a task item is updated so that I can assign the
> > content of the calculated field into the new integer field?
> > (Or any other work-around to sort by calculated field?)
> > Thanks!
> >


>
 
Re: Sorting tasks by calculated field - automatically update task-

You are attempting to set an Inspectors object collection to an interface.

That line should read:

Set myInspectors = Application.Inspectors

"BMunk" <BMunk> wrote in message

news:9EE429E5-BE5E-4591-844E-826702D8FFC8@microsoft.com...
> 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!

>

>>
 
Re: Sorting tasks by calculated field - automatically update task-

To get an event when any item in the Items collection of the Tasks folder is

changed put this line at the top of the ThisOutlookSession class with the

other declarations:

Dim WithEvents colItems As Outlook.Items

Then in your Application_Startup() handler put this:

Set colItems = Application.Session.GetDefaultFolder(olFolderTasks).Items

That will let you handle the ItemChange event on that Items collection. You

will get a reference to the item being changed. It will not tell you what

property was changed.

For that you would have to instantiate a separate TaskItem declared

WithEvents for every member of the Selection collection when the

ActiveExplorer.CurrentFolder is the Tasks folder. You'd have to change those

instantiated items each time selection changed or the view moved to a

different folder.

"BMunk" <BMunk> wrote in message

news:7C171360-1122-40AD-8836-60AE6407D697@microsoft.com...
> How can I get an event when any task in the task folder has any of it's
> properties updated? (e.g. Status set to "Deferred")?
 
Re: Sorting tasks by calculated field - automatically update task-

Thanks!
wrote:


> To get an event when any item in the Items collection of the Tasks folder is
> changed put this line at the top of the ThisOutlookSession class with the
> other declarations:

> Dim WithEvents colItems As Outlook.Items

> Then in your Application_Startup() handler put this:

> Set colItems = Application.Session.GetDefaultFolder(olFolderTasks).Items

> That will let you handle the ItemChange event on that Items collection. You
> will get a reference to the item being changed. It will not tell you what
> property was changed.

> For that you would have to instantiate a separate TaskItem declared
> WithEvents for every member of the Selection collection when the
> ActiveExplorer.CurrentFolder is the Tasks folder. You'd have to change those
> instantiated items each time selection changed or the view moved to a
> different folder.

> >

>

> "BMunk" <BMunk> wrote in message
> news:7C171360-1122-40AD-8836-60AE6407D697@microsoft.com...
> > How can I get an event when any task in the task folder has any of it's
> > properties updated? (e.g. Status set to "Deferred")?


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Outlook 2016 Arrange tasks by date, additional custom sorting, but still use friendly terms like Today, Tomorrow, This week? Using Outlook 1
R Sorting and crossing over project tasks in project window (BCM 2010) BCM (Business Contact Manager) 1
P Sorting Task List so tasks with no due date end up at the bottom Using Outlook 4
M Sorting by Day in Date Column Advanced Filter BCM (Business Contact Manager) 1
E Mail sorting view issue Using Outlook 1
P Is there any way of sorting the task list in CALENDAR view? Using Outlook 4
M Sorting messages by read/unread status Using Outlook 8
B How do I REALLY disable Outlook Junk E-mail sorting in OL2010 and/or 2013? Using Outlook 1
D Question re: Grouping by Due Date vs. Sorting by Due Date Using Outlook 1
J Outlook 2013 Sorting and grouping on 2 date fields Using Outlook 1
M Sorting "sent emails" is not logical. Is there a better way. Using Outlook 4
D Macro for sorting email according to sender and subject Using Outlook 0
S Sorting by combined categories in Outlook Using Outlook 1
M 2010: sorting by ORIGINAL send date Using Outlook 1
B Sorting suggested times in room finder Using Outlook 1
A Sorting of existing contact in Outlook 2003 just will not sort Using Outlook 2
B Outlook tasks and PDF Using Outlook 4
petunia Outlook tasks module sunsetting? Exchange Server Administration 3
Fozzie Bear Shared Calendar For Scheduled Tasks Using Outlook.com accounts in Outlook 3
R unable to filter tasks when start date is on or before today Using Outlook 3
S Sync Outlook (2021) tasks with Microsoft To Do Using Outlook 1
S Appointment font size when printing only changes Tasks' font Using Outlook 0
L Format Lost between Tasks and To Do Using Outlook 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
V Backup Calendar, Contacts, Tasks in an POP3 data file Using Outlook 3
V Outlook 2016 iCloud for Windows - Why no working Calendars and Tasks ? Using Outlook 1
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
kburrows Reset Date to Keep Tasks from Archiving Using Outlook 9
O Moving "tasks" to inbox in Outlook 2016 Using Outlook 1
O Tasks - how to display "snoozed" tasks and snooze-times? Using Outlook 7
T Outlook 2010 Tasks are not visible in To Do list Using Outlook 5
T Outlook creating unwanted tasks in Tasks and Todo from emails Using Outlook 1
S Copy Tasks/Reminders from Shared Mailbox to Personal Tasks/Reminders Outlook VBA and Custom Forms 0
V Outlook 2016 Multiple recurring tasks getting created Using Outlook 0
peterbata Shared Tasks Outlook for Mac Using Outlook 5
K Outlook tasks formatting Using Outlook 4
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
O Outlook tasks - Add text column with multiple lines Using Outlook 3
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
G Recurring tasks break links Outlook 2016 Using Outlook 5
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
P Outlook tasks not syncing with iCloud Using Outlook 2
P Searching tasks that are archived Using Outlook 4
B All imported tasks appear in to-do list Using Outlook 3
T Extract Data From Outlook Tasks Using Outlook 0
T Extract Data From Outlook Tasks Using Outlook 0

Similar threads

Back
Top