Export Email Body Table and Text To Excel In Outlook RRS feed

  • Question

  • Hello Guys,

    Hoping you can help me with this Script,

    I recieved lots emails that contain text and tables daily.

    I was testing the following scrip,

    but I need that additionally to add any table in the email, this script can includes the text keeping it the original text format.

    Sub ImportTableToExcel(MailItem As Outlook.MailItem)
    Dim Table As Word.Table
    Dim Doc As Word.Document
    Dim Excel As Excel.Application
    Dim Wb As Workbook
    Dim Ws As Worksheet
    Dim I As Integer
    Dim XRow As Integer
    On Error Resume Next
    Set Excel = New Excel.Application
    Set Wb = Excel.Workbooks.Add
    Excel.Visible = True
    Set Ws = Wb.Sheets(1)
    xRow = 1
    For Each MailItem In Application.ActiveExplorer.Selection
        SetDoc = MailItem.GetInspector.WordEditor

    For I = 1 To Doc.Tables.Count
            Set Table = Doc.Tables(I)
            Row = xRow + Table.Rows.Count + 1
            Ws.Range("A" & CStr(xRow)).Select
    End Sub

    Monday, September 3, 2018 3:02 AM

All replies