?
Solved

Handle the TaskItem's Open event

Posted on 2003-03-29
4
Medium Priority
?
691 Views
Last Modified: 2012-08-13
Hi

I've been trying to figure out how to recieve an event i VBA when the user tries to open a task. I've created an object, but I guess I have to initialize this somehow. Hope someone can help..

Here's what I've got:

Dim WithEvents myTaskItem As Outlook.TaskItem

Private Sub myTaskItem_Open(Cancel As Boolean)
    MsgBox "Opening task"
End Sub
0
Comment
Question by:ToHo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mesch
ID: 8233435
Hey ToHo,

I think this is a good sample. It's form the Outlook VBA help file. I think you forgot the initialize handler.

Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
    Set myOlItems = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
    Dim myOlMItem As Outlook.MailItem
    Dim myOlAtts As Outlook.Attachments
    Set myOlMItem = myOlApp.CreateItem(olMailItem)
    myOlMItem.Save
    Set myOlAtts = myOlMItem.Attachments
    ' Add new contact to attachments in mail message
    myOlAtts.Add Item, olByValue
    myOlMItem.To = "Sales Team"
    myOlMItem.Subject = "New contact"
    myOlMItem.Send
End Sub

</norbert>
0
 
LVL 2

Author Comment

by:ToHo
ID: 8233624
Hi norberg, and thanks for your response.

I've figured out how to handle events generally, but it's the event triggered when a task is opened I have a hard time with.

What I'm trying to achieve is to check when a task is opened if has one of my custom properties, and open a custom form if it does. Else I just want the regular task form to be launced.

I've gotten this to work if I declare a task with withevents and use this to create a new task, but this will only work with this one task. I want to catch an event on all opened task.. Maybe I'll have to write a com-plugin to achieve this, but I'm hoping there's is an easier way (ex. VBA)
0
 
LVL 2

Author Comment

by:ToHo
ID: 8253030
Hi

I figured it out; I had to make a collection of classes to receive the events.
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8261321
PAQ'd and all 125 points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read this checklist to learn more about the 15 things you should never include in an email signature.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question