Results 1 to 13 of 13
  1. #1
    Tim Bankerd
    Guest

    Using VBA to create a Task within an App. (Outlook 2000)

    Hello everyone,
    I've discovered the help files for creating a New Task in Outlook using VBA from a MS Access2k App I've created. This I can do. What I'm trying to do is develop a method of displaying the recurring tasks from within my MS Access App via VBA. I'm not sure of the syntax for fetching a task that is due within a date span, and displaying the task information.
    Does anyone have a piece of sample code that does anything like this in Outlook 2k?

    TIA,

  2. #2
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    I'm trying to do the same thing myself. The attached help file gets you going but not far enough for me. I'm watching this thread to see what else comes !
    Regards Ken

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Also - what data structure have you established in access to store recurring tasks?

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Tim
    I would have thought an easy way to do it from Access would be to open Outlook from code at a given time which would then pop up the due task. I used to automatically run a query if a particular form was opened before 8.15am (don't ask!!).
    Form_OnOpen
    if time is less than X
    CreateObject(etc)
    exit
    Something like that! It depends on your users of course but it could work if they're disciplined (?) or if it's just for you.
    Peter

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    G'day JohnBF
    ... Actually I'm stealing someone's thread here, but anyway ...
    I'm developing some task management software in Access. I'm putting in the ability to synch the tasks from my system into Outlook. That part is reasonably straight forward (he says!). But I want to establish recurrent tasks in my database, and synch those to Outlook to. What I'm having conceptual difficulty is understanding how Outlook manages recurring tasks (and the exceptions that occur as well) and the data structure it uses, so that I can mirror that data structure in my database to minimise the effort required to do the synchronisation. Any thoughts?
    Ken

  6. #6
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    For that my software would have to be running all the time - I prefer to synch my tasks accross to Outlook when they are created.

    But the original query was about recurring tasks:

    I'm developing some task management software in Access. I'm putting in the ability to synch the tasks from my system into Outlook. That part is reasonably straight forward (he says!). But I want to establish recurrent tasks in my database, and synch those to Outlook to. What I'm having conceptual difficulty is understanding how Outlook manages recurring tasks (and the exceptions that occur as well) and the data structure it uses, so that I can mirror that data structure in my database to minimise the effort required to do the synchronisation. Any thoughts?
    Ken

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Um, thoughts? Exposure of the Outlook Object Model is limited (XP is less so than 2000, and I haven't yet looked at 2003) and to my way of thinking kind of arcane, but part of that is because Outlook is a Appointment/Journal/Notes/Task wrapper on top of a Client MAPI server. Have a look at all the Task Item Properties in VB Help, and the MicroEye Outlook Object Model maps. For more 'under the hood' stuff with Extened MAPI see if CDOLive has anything on Tasks.
    -John ... I float in liquid gardens
    UTC -7DS

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Ken
    I can transfer dates to Outlook from Access and set up recurrence patterns if the needed. Sometimes for me an appointment may last 3 days or repeat over a couple of weeks so instead of entering it in Access several times I have a field that contains the recurrence number. If this is more than 1 the code automatically sets up the recurrence pattern. Is this what you want? If so, I can show you my code and you can adapt it.
    Peter

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    <P ID="edit" class=small>(Edited by JohnBF on 14-Jan-04 09:02. Corrected Code.)</P>Are you asking to pop up a specific Outlook Task Item in the standard Task Item Form from VBA code running in Access? If so, here's some Outlook starter code that uses the subject and searches the default Task Folder, and shows some of the date properties if you need to apply logic on those.

    Sub testdisplay()
    Call showtask("My Task Subject Line")
    End Sub

    Function showtask(strTaskSubject As String)
    Dim OlApp As Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olTaskFolder As Outlook.MAPIFolder
    Dim itmTask As TaskItem
    Dim boolFound As Boolean

    On Error Resume Next
    Set OlApp = GetObject(, "Outlook.Application")
    If OlApp Is Nothing Then _
    Set OlApp = CreateObject("Outlook.Application")
    Set olNS = OlApp.GetNamespace("MAPI")
    Set olTaskFolder = olNS.GetDefaultFolder(olFolderTasks)
    For Each itmTask In olTaskFolder.Items
    If itmTask.Subject = strTaskSubject Then
    MsgBox "Created: " & itmTask.CreationTime _
    & vbLf & "Start: " & itmTask.StartDate & vbLf _
    & "Due: " & itmTask.DueDate
    itmTask.Display
    boolFound = True
    End If
    Next itmTask
    If Not boolFound Then MsgBox "No matching Task found"

    Set itmTask = Nothing
    Set olTaskFolder = Nothing
    Set olNS = Nothing
    Set OlApp = Nothing
    End Function
    -John ... I float in liquid gardens
    UTC -7DS

  10. #10
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Basically I have a database that stores user created tasks. These tasks come with DueToStart and ToBeComplete Dates. Based on user input, I will potentially want an e-mail sent when a Task is DueToStart but hasn't, Has Started, DueToComplete, but hasn't, and Is Complete. These notifications could go either to the creator or the receiver of the task.

    In addition, I will want the ability to create reminder tasks in Outlook, based again on user input, for DueToStart and DueComplete dates - potentially for the creator as well as the receiver. All so far I'm confident of achieving.

    But I would like to program in the ability to create recurring tasks into the database. Tasks that will self generate some time later after the most recent instance is complete, and Tasks that will spawn a series of separate occurrences in the database - much as Outlook does. Somehow Outlook manages to generate recurring tasks, with exceptions, that can still be deleted in one action.

    So I'm seeking to understand how the various fields in Task Items contribute to the total ability for Outlook to create and maintain Tasks. So I can then create in Outlook programatically from Access any kind of recurring task that I could do with the interface of Outlook.

    I'd love to see your code!

    Thanks, Regards Ken

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Out

    OTOH - you aren't someone in need of running Microsoft Project, by any chance?
    Gre

  12. #12
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Out

    Oh! You are So Cruel!

    Actually this software I'm working on has quite a different slant.

    Ken

  13. #13
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using VBA to create a Task within an App. (Outlook 2000)

    Ken
    Sorry it's been a while but I think you're doing something similar to me so here's part of my code. I assume you know the set up stuff. Mine is for one item at a time but you could set up a loop of course. RecurrenceType is a long number and you can add RecurrenceInterval. (See OL Help)

    'Write values from variables to fields in the new appt item
    With itm
    .Subject = "Training Session at " & strSubject & " (No " & lngNo & ")"
    .start = dteStart
    .Location = strLocation
    .End = dteFinish
    .ClearRecurrencePattern
    'I found that for some reason you need to clear before you set even tho you think it is clear
    'add recurrence pattern for training session if more than 1 day
    If lngDuration > 1 Then
    Set myRecur = .GetRecurrencePattern
    With myRecur
    .RecurrenceType = olRecursDaily 'or weekly monthly etc
    .PatternEndDate = dteEndDate
    End With
    strMsg = "DATES TRANSFERRED." & NL _
    & "DON'T FORGET THE WALL CHART."
    End If
    .Close (olSave)
    End With
    'add task reminder for recontact
    Set itmT = itms.Add("IPM.Task")
    With itmT
    .Subject = "Send Training follow-up letter to " & strSubject
    .DueDate = dteEndDate + 63
    .Close (olSave)
    End With

    Hope this helps.
    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •