title: Copy table in email to Excel using VBA
body: <p>I am trying to create some code that will copy the body of an email into a new Excel spreadsheet. I have this code:</p>
  
  <pre><code>Public Sub ExportToExcel1()
  
  Dim ns As NameSpace
  Dim Inbox As MAPIFolder
  Dim myitem As Outlook.MailItem
  Dim FileName As String
  Dim i As Integer
  Dim objSearchFolder As Outlook.MAPIFolder
  Dim item As Object
  Dim mai As MailItem
  
  Set ns = GetNamespace("MAPI")
  Set Inbox = ns.GetDefaultFolder(olFolderInbox).Folders("Hold Info")
  Set objSearchFolder = Inbox
  
  i = 0
  For Each item In Inbox.Items
      item.Display
      item.Body.Select
      Selection.Copy
      Dim xlApp As Object ' Excel.Application
      Dim xlWkb As Object ' Excel.Workbook
      Set xlApp = CreateObject("Excel.Application") ' New Excel.Application
      Set xlWkb = xlApp.Workbooks.Add
      xlApp.Visible = True
      xlApp.Workbooks.Add
      xlApp.Selection.Paste False, False, False
  Next 
  
  End Sub
  </code></pre>
  
  <p>It keeps giving me an error at <code>item.Body.Select</code> and I have no clue why. It may have something to do with the fact that the email I am trying to copy is nothing but tables that were generated in Oracle, but I have no clue.</p>