|
|
| Next: Problem with Rectangle |
| Author |
Message |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Wed Mar 11, 2009 3:50 am Post subject: Sorting tasks by calculated field - automatically update task-fiel Archived from groups: microsoft>public>outlook>program_vba (more info?) |
|
|
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! |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo External

Since: Oct 17, 2003 Posts: 3355
|
Posted: Wed Mar 11, 2009 9:17 am Post subject: Re: Sorting tasks by calculated field - automatically update task-fiel [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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().
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"BMunk" <BMunk.TakeThisOut@discussions.microsoft.com> 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!
> |
|
| Back to top |
|
 |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Wed Mar 11, 2009 9:17 am Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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!
"Ken Slovak - [MVP - Outlook]" 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().
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "BMunk" <BMunk.TakeThisOut@discussions.microsoft.com> 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!
> >
>
> |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo External

Since: Oct 17, 2003 Posts: 3355
|
Posted: Wed Mar 11, 2009 4:11 pm Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"BMunk" <BMunk.TakeThisOut@discussions.microsoft.com> 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! |
|
| Back to top |
|
 |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Wed Mar 11, 2009 4:11 pm Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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.
"Ken Slovak - [MVP - Outlook]" 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.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "BMunk" <BMunk.RemoveThis@discussions.microsoft.com> 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!
>
> |
|
| Back to top |
|
 |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Wed Mar 11, 2009 4:44 pm Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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.
>
>
> "Ken Slovak - [MVP - Outlook]" 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.
> >
> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Author: Professional Programming Outlook 2007.
> > Reminder Manager, Extended Reminders, Attachment Options.
> > http://www.slovaktech.com/products.htm
> >
> >
> > "BMunk" <BMunk.TakeThisOut@discussions.microsoft.com> 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!
> >
> > |
|
| Back to top |
|
 |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Wed Mar 11, 2009 5:40 pm Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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")?
"Ken Slovak - [MVP - Outlook]" 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().
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "BMunk" <BMunk RemoveThis @discussions.microsoft.com> 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!
> >
>
> |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo External

Since: Oct 17, 2003 Posts: 3355
|
Posted: Thu Mar 12, 2009 10:59 am Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
You are attempting to set an Inspectors object collection to an interface.
That line should read:
Set myInspectors = Application.Inspectors
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"BMunk" <BMunk.RemoveThis@discussions.microsoft.com> 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.
>
>
> "Ken Slovak - [MVP - Outlook]" 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.
>>
>> --
>> Ken Slovak
>> [MVP - Outlook]
>> http://www.slovaktech.com
>> Author: Professional Programming Outlook 2007.
>> Reminder Manager, Extended Reminders, Attachment Options.
>> http://www.slovaktech.com/products.htm
>>
>>
>> "BMunk" <BMunk.RemoveThis@discussions.microsoft.com> 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!
>>
>> |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo External

Since: Oct 17, 2003 Posts: 3355
|
Posted: Thu Mar 12, 2009 11:06 am Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"BMunk" <BMunk RemoveThis @discussions.microsoft.com> 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")? |
|
| Back to top |
|
 |
BMunk External

Since: Mar 11, 2009 Posts: 6
|
Posted: Fri Mar 13, 2009 3:28 am Post subject: Re: Sorting tasks by calculated field - automatically update task- [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Thanks!
"Ken Slovak - [MVP - Outlook]" 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.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "BMunk" <BMunk.RemoveThis@discussions.microsoft.com> 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")?
>
> |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|