Consulting

Results 1 to 8 of 8

Thread: Outlook 2007 Updated Task

  1. #1
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location

    Outlook 2007 Updated Task

    The following code updates a Task based on the different fields I change re the Contact that is assigned to it.....so in my contact form, I have many fields that show up on the P2 folder of the Task......but, it only updates a Task where the contact name of the the task is my name....not any other contact I select....so what should we fix so it identifies any contact I select to update the task...as if it was my name three times, it updates all tasks for the three contacts of my name....so I just need to have it identify any contacts I select, not just my name....thanks much:

    Sub Group_Update_Task2()
      'Dim objApp As Application
      'Dim objNS As NameSpace
      'Dim objFolder As MAPIFolder
    ' Dim objMsg As MailItem
      Dim ObjItem As Object
     ' Dim remoteObj
      
      'Dim ContactName
       ' Dim olns
        'Dim MyFolder
        'Dim NumItems
       ' Dim myItems
        'Dim TaskCount
     
      
      Dim Str, Str1, Str2, Str3, Str4, Str5, Str6, Str7, Str8, Str9, Str10, Str11, Str12, Str13, Str14, Str15, Str16, Str17, Str18, Str19, Str20, Str21, Str22
    Dim StartDate
    Dim DueDate
    Dim myItem
      
    Set oContact = ObjItem
      Set objApp = CreateObject("Outlook.Application")
      Set objNS = objApp.GetNamespace("MAPI")
      
          Set objSelection = objApp.ActiveExplorer.Selection
                    
              For Each ObjItem In objSelection
                                 
        
        TaskCount = 0
        Str = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox7").value
        Str1 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox8").value
        Str2 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox5").value
        Str3 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Initial Intro").value
        Str4 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Intro Date").value
        Str5 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox10").value
        Str6 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox3").value
        Str7 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox2").value
        Str8 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox4").value
        Str9 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox5").value
        Str10 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ContactTypeComboBox1").value
        Str11 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox4").value
        Str12 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("StatusComboBox1").value
        Str13 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox20").value
        Str14 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox6").value
        Str15 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox22").value
        Str16 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox9").value
        Str17 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Follow-Up ComboBox1").value
        Str18 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox3").value
        Str19 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("NextStepComboBox1").value
        Str20 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox14").value
        Str21 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox25").value
        Str22 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox29").value
    
    
        
        StartDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl4").value
        DueDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl3").value
    
    
    
    
        ContactName = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Fullname").value
        Set olns = ObjItem.Application.GetNamespace("MAPI")
        Set MyFolder = olns.GetDefaultFolder(13)
        NumItems = MyFolder.items.Count
       Set myItems = MyFolder.items
    
    
        If NumItems > 0 Then
        For i = 1 To NumItems
            Set Recipients = myItems(i).Recipients
            If Recipients.Count > 0 Then
            
            If myItems(i).Links.Item(1).Name = ContactName Then
    
    
                myItems(i).Display
               myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox20").value = Str
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox7").value = Str1
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox24").value = Str2
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox25").value = Str3
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox26").value = Str4
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox23").value = Str5
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox8").value = Str6
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox9").value = Str7
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox10").value = Str8
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox11").value = Str9
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox12").value = Str10
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox13").value = Str11
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox14").value = Str12
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox15").value = Str13
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox16").value = Str14
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox22").value = Str15
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox21").value = Str16
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox17").value = Str17
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox18").value = Str18
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox19").value = Str19
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox28").value = Str20
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox29").value = Str21
                myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox27").value = Str22
                myItems(i).StartDate = StartDate
                myItems(i).DueDate = DueDate
    
    
    
    
                myItems(i).Save
                myItems(i).Close (0)
                TaskCount = TaskCount + 1
            End If
           End If
        Next
        
        
        
        End If
    
    
        Select Case TaskCount
            Case 0
               MsgBox "No tasks were updated."
            Case 1
                MsgBox "One task was update successfully."
            Case Else
                MsgBox TaskCount & " tasks were updated successfully."
        End Select
    
    
    
    
    
    
      
            Next
         Set objMsg = Nothing
      Set ObjItem = Nothing
      Set objFolder = Nothing
      Set objNS = Nothing
      Set objApp = Nothing
    End Sub

  2. #2
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Any thoughts from anyone?

  3. #3
    so I just need to have it identify any contacts I select
    as i posted somewhere else
    afaik you can not return the selected contacts or links (or any other selection) from within a task item

    while it may be possible to do, it will not be simple with outlook code, would require the use of several API functions

  4. #4
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    I appreciate your input......and I don't have any experience re codes or API functions....so if someone knows what to change and add functions to the macro area....happy to hear back....and if not, I understand.....

    And, just as a reminder, the code I posted does it just as if the contact in the task, is my name.....so that's a little different as maybe that code could identify any contact....just in case......

    And again, i appreciate the the help from westconn1 thanks very much.....and also in that other thread I asked one additional question after you showed me how to use the times list

  5. #5
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    And also, here is the code that when I select several contacts, it creates a new Task to each contact i select.....and the code I posted above only updates my contact...so just in case some one has any idea to do this where it updates the tasks re the contacts I select...not from the task select, but just from the list of contacts

    Sub Group_Create_Task()  Dim objApp As Application
      Dim objNS As NameSpace
      Dim objFolder As MAPIFolder
     Dim objMsg As MailItem
      Dim ObjItem As Object
      Dim remoteObj
      
      Dim Str, Str1, Str2, Str3, Str4, Str5, Str6, Str7, Str8, Str9, Str10, Str11, Str12, Str13, Str14, Str15, Str16, Str17, Str18, Str19, Str20, Str21, Str22
    Dim StartDate
    Dim DueDate
    Dim myItem
      
    Set oContact = ObjItem
      Set objApp = CreateObject("Outlook.Application")
      Set objNS = objApp.GetNamespace("MAPI")
      
          Set objSelection = objApp.ActiveExplorer.Selection
                    
               For Each ObjItem In objSelection
                
                
        
    
    
    
    
    Str = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox7").value
    Str1 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox8").value
    Str2 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox5").value
    Str3 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Initial Intro").value
    Str4 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Intro Date").value
    Str5 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox10").value
    Str6 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox3").value
    Str7 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox2").value
    Str8 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox4").value
    Str9 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox5").value
    Str10 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ContactTypeComboBox1").value
    Str11 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox4").value
    Str12 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("StatusComboBox1").value
    Str13 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox20").value
    Str14 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox6").value
    Str15 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox22").value
    Str16 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox9").value
    Str17 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Follow-Up ComboBox1").value
    Str18 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox3").value
    Str19 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("NextStepComboBox1").value
    Str20 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox14").value
    Str21 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox25").value
    Str22 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox29").value
    
    
    
    
    
    
    
    
    
    
    Set myItem = Application.CreateItemFromTemplate("C:\Users\Stoler Law\AppData\Roaming\Microsoft\Templates\Task Follow-Up.oft")
    
    
    
    
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox20").value = Str
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox7").value = Str1
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox24").value = Str2
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox25").value = Str3
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox26").value = Str4
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox23").value = Str5
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox8").value = Str6
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox9").value = Str7
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox10").value = Str8
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox11").value = Str9
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox12").value = Str10
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox13").value = Str11
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox14").value = Str12
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox15").value = Str13
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox16").value = Str14
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox22").value = Str15
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox21").value = Str16
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox17").value = Str17
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox18").value = Str18
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox19").value = Str19
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox28").value = Str20
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox29").value = Str21
    myItem.GetInspector.ModifiedFormPages("P.2").Controls("TextBox27").value = Str22
    
    
    StartDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl4").value
    
    
    DueDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl3").value
    
    
    myItem.StartDate = StartDate
    
    
    myItem.DueDate = DueDate
    
    
    
    
    myItem.Links.Add ObjItem
    myItem.Display
    
    
    'myItem.Save
      
            Next
         Set objMsg = Nothing
      Set ObjItem = Nothing
      Set objFolder = Nothing
      Set objNS = Nothing
      Set objApp = Nothing
    End Sub

  6. #6
    activeexplorer refers to the currently showing main outlook window, so can be any folder tasks list or contacts list etc
    the selection for the above can return all the selected items in the list or folder

    i do not believe you can do like this to return the selection from any open item

  7. #7
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    The contacts are not open. I just select them from a contact folder or subfolder. And the task macro creates a task for each contact I select, but the task update does not do it for any contact unless its my name. Anything to fix please?

  8. #8
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    The contact that was not updating had something in it that got in the way of it, but the other contacts I select are now updated the tasks for those contacts....so the code above works....

    Just wanted to let all know.
    Last edited by lms; 01-26-2014 at 08:29 AM.

Posting Permissions

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