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

Ken Slovak - [MVP - Outlook]

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

Qk11bms

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


>
 
K

Ken Slovak - [MVP - Outlook]

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

Qk11bms

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!


>
 
Q

Qk11bms

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!

> >
 
Q

Qk11bms

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


>
 
K

Ken Slovak - [MVP - Outlook]

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!

>

>>
 
K

Ken Slovak - [MVP - Outlook]

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")?
 
Q

Qk11bms

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.
Thread starter Similar threads Forum Replies Date
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
A Tasks not sorting correctly Using Outlook 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
G Outlook 2003:Inbox 'FROM' sorting option Using Outlook 1
S Sorting out sent messages. How can I consolidate 3 sent message directories and successfully retain sent messages across 3 differnt computers using th Using Outlook 2
M Re: Outlook 2010 - Email folders sorting constantly changing Using Outlook 2
B Contacts not sorting in "File As" sort order Using Outlook 3
B Sorting Contacts by Birthday or Anniversary Using Outlook 6
M Strange sorting in sort by day Using Outlook 2
G Managing / Sorting Address Book Contacts into groups Using Outlook 1
A Sorting of existing contact in Outlook 2003 just will not sort Using Outlook 2
O e-mail list sorting Using Outlook 4
B Sorting of Folders in Outlook 2010 Using Outlook 2
J Outlook multiple selection dropping when changing sorting Using Outlook 1
H Sorting Contacts Using Outlook 3
A Sorting 'sent' email messages Using Outlook 1
J When sorting by subject, I don't get taken to the highlighted e-mail anymore Using Outlook 1
A Sorting by categories in Outlook makes items in a folder disappear Exchange Server Administration 5
M Need HELP on sorting out multiple Outlook DATA files into ONE via: Compare, Delete Dups, Merge into ONE DATA FILE Using Outlook 6
E Outlook 2010 - Mail Folders Sorting Changes Constantly Using Outlook 2
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
I To-do bar (tasks) Using Outlook 1
O Tasks - Is there a postponed date column? Using Outlook 7
O Outlook 365 - Tasks are not synchronizing? Using Outlook 7
F some tasks are disappearing Using Outlook 4
F How to show assigned tasks under certain mailbox? Using Outlook 4
B iCloud Option to sync contacts, mail, calendar and tasks Using Outlook 5
M tasks in todo list appearing twice Using Outlook 3
J what file contains contacts, tasks and appointments stored locally? Using Outlook 1
F Finding Meetings/Tasks in a date range Using Outlook 1
F Sharepoint tasks from multiple accounts in To-Do List Using Outlook 8
Similar threads


















































Top