Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update from Project in Outlook (2003)

    I have the code below to take some tasks in Project and update Outlook. This piece of code has been working for years and since yesterday it has not done its job. The task in Outlook are not updated according to the information modified in Project.
    Any suggestions will be appreciated.
    Thanks and regards,
    Marcel

    Sub UpdateAllTaskToOutlook()
    Dim appOutlk As Outlook.Application
    Dim oFolders As Outlook.Folders
    Dim oSpace As Outlook.NameSpace
    Dim oFolder As Outlook.MAPIFolder
    Dim oTasks As Outlook.Items
    Dim oTask As Outlook.TaskItem
    Dim pSeln As MSProject.Selection

    Dim pTasks As MSProject.Tasks
    Dim pTask As MSProject.Task

    Dim lngTasks As Long
    Dim UpdatedTasks As Long
    Dim i As Long

    'how many tasks selected ?
    MSProject.Application.SelectAll
    Set pSeln = MSProject.Application.ActiveSelection
    MSProject.Application.SelectBeginning

    UpdatedTasks = 0

    With pSeln.Tasks
    lngTasks = .Count
    If lngTasks > 0 Then
    On Error GoTo noOutlook
    Set appOutlk = GetObject(, "outlook.application")
    On Error GoTo 0

    Set oSpace = appOutlk.GetNamespace("MAPI")
    Set oFolder = oSpace.GetDefaultFolder(olFolderTasks)


    'With oFolder
    For i = 1 To lngTasks

    Set pTask = .Item(i)
    If pTask.Text1 <> "" Then
    Set oTask = oFolder.Items.Find("[BillingInformation] = " & pTask.Text1)
    UpdatedTasks = UpdatedTasks + 1
    With oTask
    'copy text & dates
    .Subject = pTask.Name
    .StartDate = pTask.Start
    .DueDate = pTask.Finish
    .TotalWork = pTask.Work

    'map any other properties here
    '.OutlookProperty1 = pTask.MatchingProperty1
    '.OutlookProperty2 = pTask.MatchingProperty2
    '.OutlookProperty3 = pTask.MatchingProperty3
    End With
    oTask.Save
    End If
    Next i
    'End With
    Else
    MsgBox "No tasks selected", vbExclamation, "Copy Tasks to Outlook"
    End If
    End With
    MsgBox Format(UpdatedTasks) & " Task(s) Updated in Outlook", vbInformation, "Copy Selected Tasks to Outlook"
    Exit Sub
    noOutlook:
    Set appOutlk = CreateObject("Outlook.Application")
    Resume Next
    End Sub

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Update from Project in Outlook (2003)

    Can you single-step through the code and see where it is either prematurely stopping or running into a problem? (Not being familiar with Project and not using Outlook Tasks, I don't know whether there's anything about those two features that might have changed in the latest security updates.)

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update from Project in Outlook (2003)

    The code runs normally. I have used the step by step option and each the step runs properly. The only point is that at the end the task is not updated in Outlook.

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

    Re: Update from Project in Outlook (2003)

    Did you take out the On Error statement and test it?
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Update from Project in Outlook (2003)

    Between steps, do you see the information in the task changing, or do the field assignments not work? Trying to figure out if the problem is at the .Save stage or somewhere else.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update from Project in Outlook (2003)

    The problem is at the save stage as all the assigments are working well.

  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: Update from Project in Outlook (2003)

    I don't see anything wrong with the code per s
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update from Project in Outlook (2003)

    I have tried to move the .save inside of the with block. No change.
    The Otask object exist but I have tried also your proposed code. No change.
    Anyway thank you for your help.
    Regards.

  9. #9
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update from Project in Outlook (2003)

    I have do it, then no error pop up but no change in the results, the tasks are still not updated in Outlook.
    Thanks and regards,
    marcel

Posting Permissions

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