title: Manipulate Excel via Outlook VBA
body: <p>I've almost got this working but I'm stuck on one part.  Here's what I'm trying to do:</p>
  
  <ol>
  <li>Save Outlook email attachment (.csv file)</li>
  <li>Open attachment in Excel</li>
  <li>Delete the last 6 lines of the file</li>
  <li>Re-save the file</li>
  </ol>
  
  <p>I'm able to save the file and get it to open in Excel, but then nothing else happens.  No matter what I try I'm unable to get any actions to happen within Excel; I can't get it to delete the last 6 rows (Parse the Footer).  Any help would be greatly appreciated!</p>
  
  <pre><code>Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
  Dim objAtt As Outlook.Attachment
  Dim saveFolder As String
  Dim attachName As String
  
  Dim oXL As Object, oWB As Object, oSheet As Object
  
  saveFolder = "C:\Temp\"
  
      For Each objAtt In itm.Attachments
          objAtt.SaveAsFile saveFolder &amp; "\" &amp; objAtt.DisplayName
          attachName = objAtt.DisplayName
          Set objAtt = Nothing
      Next
  
  
  ' Start Excel and get Application object
  Set oXL = CreateObject("Excel.Application")
  
  ' Hide Excel
  oXL.Visible = False
  
  ' Open the File
  Set oWB = oXL.Workbooks.Open(saveFolder &amp; attachName)
  
  'Set the Worksheet
  Set oSheet = oWB.Sheets("Sheet1")
  
  'Parse the Footer
  ActiveCell.SpecialCells(xlLastCell).Select
  ActiveCell.Offset(-5, 0).Range("A1:A6").Select
  ActiveCell.Activate
  Selection.ClearContents
  
  'Save the File
  Set oWB = oXL.Workbooks.Save(saveFolder &amp; "\" &amp; objAtt.DisplayName)
  
  'Clean Up
  oWB.Close (True)
  oXL.Quit
  Set oWB = Nothing
  Set oXL = Nothing
  
  End Sub
  </code></pre>