Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / October 2005

Tip: Looking for answers? Try searching our database.

Code to automate tasks in Outlook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vonclausowitz@gmail.com - 04 Oct 2005 19:27 GMT
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
Pedro CR - 05 Oct 2005 04:05 GMT
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.

> Goodday all,
>
[quoted text clipped - 12 lines]
> Regards
> Marco
Michael Bauer - 05 Oct 2005 09:36 GMT
Am 4 Oct 2005 11:27:10 -0700 schrieb vonclausowitz@gmail.com:

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.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Goodday all,
>
[quoted text clipped - 12 lines]
> Regards
> Marco
vonclausowitz@gmail.com - 05 Oct 2005 18:27 GMT
Is there an example of VB code for Outlook tasks to do so?

Marco
Michael Bauer - 06 Oct 2005 22:47 GMT
Am 5 Oct 2005 10:27:35 -0700 schrieb vonclausowitz@gmail.com:

A sample for the ItemChange event is available in the VBA help. Another
one for the Explorer wrapper on
http://www.microeye.com/resources/ItemsCB.zip

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Is there an example of VB code for Outlook tasks to do so?
>
> Marco
vonclausowitz@gmail.com - 08 Oct 2005 10:38 GMT
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
Michael Bauer - 08 Oct 2005 11:52 GMT
Am 8 Oct 2005 02:38:56 -0700 schrieb vonclausowitz@gmail.com:

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.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> 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
vonclausowitz@gmail.com - 08 Oct 2005 13:01 GMT
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
Michael Bauer - 08 Oct 2005 16:52 GMT
Am 8 Oct 2005 05:01:30 -0700 schrieb vonclausowitz@gmail.com:

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

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Wooh,
>
[quoted text clipped - 6 lines]
>
> Marco
vonclausowitz@gmail.com - 08 Oct 2005 18:55 GMT
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
Michael Bauer - 08 Oct 2005 19:25 GMT
Am 8 Oct 2005 10:55:58 -0700 schrieb vonclausowitz@gmail.com:

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

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Michael,
>
[quoted text clipped - 9 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.