Consulting

Results 1 to 2 of 2

Thread: Import custom Outlook 2010 tasks from Excel 2010 using VBA

  1. #1
    VBAX Newbie
    Joined
    Nov 2013
    Posts
    1
    Location

    Import custom Outlook 2010 tasks from Excel 2010 using VBA

    I have a list of tasks in an Excel worksheet that includes custom fields that have already been created in Outlook. As an example, I have a custom task field named Project. I would like to import these tasks into Outlook. I keep getting the
    Run-time error '91': Object variable or With block variable not set
    error. I have the following code:

    Sub Test2()
        Dim olApp As Outlook.Application
        Dim olTask As Outlook.TaskItem
        Dim olItem As Object
        Dim myFields As Outlook.UserProperty
                
        ' Select cell A2, *first line of data*.
        Range("A2").Select
          
        ' Set Do loop to stop when an empty cell is reached.
        Do Until IsEmpty(ActiveCell)
            Set olApp = New Outlook.Application
            Set olTask = olApp.CreateItem(olTaskItem)
                      
             
                    
            With olTask
                
                .UserProperties.Find("Project", True) = Cells(ActiveCell.Row, 2)
                '.Subject = Cells(ActiveCell.Row, 5)
                .Save
            End With
            
            Set olTask = Nothing
            Set olApp = Nothing
            'Step down 1 row from present location.
            ActiveCell.Offset(1, 0).Select
        
        Loop
        
        
        
    End Sub
    Any thoughts or ideas are welcome. Snarky comments are not. Please assume I've done my very best to search for answers before posting. Thank you!

    Patricia

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645

Posting Permissions

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