Code to automate tasks in Outlook

V

vonclausowitz

Goodday all,

I want to know if it is possible to create some VB code to update field
in Outlook tasks on a click event.
I have created a user-defined field named Updater in my Outlook tasks.
I want to get this field updated automatically when I click a Task away
as Completed.
In other words:

When I clikc on a Task to complete it the field Updater must be edited
and updated with mu Username automatically...

Is this possible?

Regards
Marco
 
P

Pedro CR

have you tryed creating a custom Task form? probably there will be some kind
of data type for it
you also have the option to write VBS (not VBA) code to automate the custom
form.
 
M

Michael Bauer

Am 4 Oct 2005 11:27:10 -0700 schrieb (e-mail address removed):

Marco, one approach is to track the folder item´s ItemChange events. If the
event is being fired then check then item´s Status property, if it´s
completed then check for your UserProperty.

Note: For the ability to track more than one folder at once you´ll also need
an Explorer wrapper, that is an instance of a class module for each Explorer
which is being opened.
 
V

vonclausowitz

I found out that it is not possible to trap the status Completed
because when you click a Task as completed then it dissapears and a new
task appears. This new task is then checked for it's status which is
then of course always not completed.

Marco
 
M

Michael Bauer

Am 8 Oct 2005 02:38:56 -0700 schrieb (e-mail address removed):

Ok, then you have to do a lot of work. You need to track every single
TaskItem. That is you need additionally an Inspector wrapper (same mechanism
as for the Explorer) and need to track the Explorer´s SelectionChange event
if its current folder is a task folder.

The goal is to receive each TaskItem´s PropertyChange event.
 
V

vonclausowitz

Wooh,

Sounds complicated. Is that a procedure which would take a long time
considering I have about 800 tasks?

How would the code look like?

Any short sample to get me starting?

Marco
 
M

Michael Bauer

Am 8 Oct 2005 05:01:30 -0700 schrieb (e-mail address removed):

I´m not sure what you´re asking for. You don´t have to reference each item
at once. You need a reference on each opened TaskItem and one on the
currently selected TaskItem (if any) in each opened Explorer. In that way
you´re able to track each TaskItem´s events, which an user could edit.

Please see also the VBA help. There´re samples for all mentioned events:
NewInspector, PropertyChange, SelectionChange.

For one TaskItem in an Explorer the code looks like this:

Private WithEvents m_oTask as Outlook.TaskItem
Private WithEvents m_oExplorer As Outlook.Explorer

Private Sub Application_Startup()
Set m_oExplorer = Application.ActiveExplorer
End Sub

Private Sub m_oExplorer_SelectionChange()
If m_oExplorer.CurrentFolder.DefaultItemType = olTaskItem Then
Set m_oTask = m_oExplorer.Selection(1)
End If
End Sub

Private Sub m_oTask_PropertyChange(ByVal Name As String)
If Name="Complete" Then
If m_oTask.Complete=True Then
' ...
Endif
Endif
End Sub
 
V

vonclausowitz

Michael,

When trying this code I get an error message saying:

"Array index out of bounds" on the next lines:

Private Sub oExplorer_SelectionChange()

If oExplorer.CurrentFolder.DefaultItemType = olTaskItem Then
----->> error ---> Set oTask = oExplorer.Selection(1)
End If

End Sub
 
M

Michael Bauer

Am 8 Oct 2005 10:55:58 -0700 schrieb (e-mail address removed):

That means there´s no item selected. You can check Selection.Count
before accessing Selection(1).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top