title: outlook "To Do" items into Excel using VBA
body: <p>First off, I'm new to VBA, with about 20 hours of training.</p>
  
  <p>I'm trying to export items from Outlook 2010 to Excel 2010.  I want to grab all the unfinished "To Do" items from Outlook and throw them into Excel with one item per row, and columns for item parameters (like Subject, Due Date, attachments, etc.).</p>
  
  <p>Here's the first pass that actually does what I explained, and imports only tasks (tasks are a subset of all to do items, from what I understand) and their Subject/Due Date:</p>
  
  <pre><code>Function GetOutlookApp() As Object
  
  On Error Resume Next
    Set GetOutlookApp = GetObject(, "Outlook.Application")
    If Err.Number &lt;&gt; 0 Then
      Set GetOutlookApp = CreateObject("Outlook.Application")
    End If
  On Error GoTo 0
  
  End Function
  
  Sub getOlTasks()
  
  Dim olApp As Object ' Outlook.Application
  Dim olnameSpace As Object ' Outlook.Namespace
  Dim taskFolder As Object ' Outlook.MAPIFolder
  Dim tasks As Object ' Outlook.Items
  Dim tsk As Object
  
  Set olApp = GetOutlookApp
  Set olnameSpace = olApp.GetNamespace("MAPI")
  Set taskFolder = olnameSpace.GetDefaultFolder(13)  'olFolderTasks is folder# 13, apparently
  Set tasks = taskFolder.Items
  
    For x = 1 To tasks.Count
  
      Set tsk = tasks.Item(x)
      Sheet1.Cells(1, 1).Activate
      Do While IsEmpty(ActiveCell) = False
        Selection.Offset(1, 0).Activate
      Loop
  
  'Fill in Data
      If Not tsk.Complete Then
        ActiveCell.Value = tsk.Subject
        Selection.Offset(0, 1).Activate
        ActiveCell.Value = tsk.DueDate
        Selection.Offset(1, -1).Activate
      End If
  
    Next x
  
  End Sub
  </code></pre>
  
  <p>I tried to do this with only "tasks" items, everything was going smoothly until I realized that tasks can't have attachments.  When I have an email w/attachment that I turn into a task, I lose the attachment.  Apparently what I need to do is import all "To Do items", rather than just tasks.</p>
  
  <p>So My questions are:</p>
  
  <p>1) What folder number is olFolderToDo?  I have seen people run code like:</p>
  
  <pre><code>Set taskFolder = olnameSpace.GetDefaultFolder(olFolderTasks) 'rather than GetDefaultFolder(13)
  </code></pre>
  
  <p>which would lead me to believe I should be able to just use olFolderToDo, but when I try to use the <em>name</em> of the folder in my first example rather than the <em>number</em>, I get an invalid argument runtime error.  If anyone knows why, I'd be interested to know.</p>
  
  <p>2) How would I go about importing an attachment from an email to a specific cell in excel?</p>