View Single Post
 
Old 04-12-2013, 04:22 AM
vodkasoda vodkasoda is offline Windows Vista Office 2007
Novice
 
Join Date: Apr 2013
Location: Stowmarket, Suffolk, UK
Posts: 15
vodkasoda is on a distinguished road
Unhappy How to update an Outlook Task in Word 2007 VBA

I actually had all of this working a few weeks ago, but managed to lose three of my Macros when I "upgraded" from WinXP to Vista !!!

I have rewritten most code and it all seems to be working, except for this bit, I can't for the life of me remember how I updated my Outlook Tasks in my Word Macro !!!

I am linked to Outlook & am able to send an E:Mail, but I then need to update a Task and can't get it working, can anybody please tell me what I need to do here ?!?

Basically, I know *exactly* what the Task will be called, I just need to open it, edit it, save it, close it ... but at the moment I can't even link to it

Code:
Sub myButtonMacro3(control As IRibbonControl)

    myDocName = Left(ActiveDocument.Name, (InStr(ActiveDocument.Name, ".doc")) - 1)
    mySession = ""
    
    While IsNumeric(Right(myDocName, 1))
        mySession = Right(myDocName, 1) + mySession
        myDocName = Left(myDocName, Len(myDocName) - 1)
    Wend
    
    myLeagueName = Left(myDocName, Len(myDocName) - 4)
    mySubject = "NewsLetter For " + myLeagueName + " Session " + mySession
    myBody = "Here you go ..."
    
     ActiveDocument.Save
    
    Set oOutlookApp = GetObject(, "Outlook.Application")

    If Err <> 0 Then
        Set oOutlookApp = CreateObject("Outlook.Application")
        bStarted = True
    End If

    Set oItem = oOutlookApp.CreateItem(olMailItem)

    With oItem
        .To = "xxx@gmail.com"
        .Subject = mySubject
        .Body = myBody
        .Attachments.Add ActiveDocument.FullName
        .Send
    End With

    If bStarted Then
        oOutlookApp.Quit
    End If
    
    UpdateCalendar '<<< Call Routine to update Task 
    
    Set oItem = Nothing
    Set oOutlookApp = Nothing

    Application.Quit


End Sub

Sub UpdateCalendar()

'The following code is NOT working code, it is just typed up from memory, but no matter what I try,
'I cannot even get the next line working & I am getting no help from the IntelliSense system !

    Set oTsk = Outlook.TaskItem
    
    For Each oTsk In oOutlookApp
        If Task.Name = myLeagueName & " Newsletter" Then
            Task.Status = olWaitingOnSomeoneElse
            Task.Complete = "75%"
            Task.Categories = "Newsletters : Sent"
            Task.Save
        End If
    Next olTsk

End Sub
Reply With Quote