Please can anyone help me with a macro that can Pick up tables in the email from and paste in Excel for multiple emails. We do have some macros online that can pickup table from one Email but wanted to do for multiple emails in a mail box and paste table one below that other. the other thing it should do is select the mails with Subject based of the email.
.....Below macro just take the table in excel
Macro for picking up for one email :
Sub ExportTablesinEmailtoExcel()
Dim objMail As Outlook.MailItem
Dim objWordDocument As Word.Document
Dim objTable As Word.Table
Dim lTableCount As Long
Dim objExcelApp As Excel.Application
Dim objExcelWorkbook As Excel.Workbook
Dim objExcelWorksheet As Excel.Worksheet
Dim i As Long
'Create a new excel workbook
Set objExcelApp = CreateObject("Excel.Application")
Set objExcelWorkbook = objExcelApp.Workbooks.Add
objExcelApp.Visible = True
'Get the table(s) in the selected email
Set objMail = Outlook.Application.ActiveExplorer.Selection.Item(1)
Set objWordDocument = objMail.GetInspector.WordEditor
lTableCount = objWordDocument.Tables.Count
If lTableCount > 1 Then
'If there is more than one table
'Copy each table into separate worksheet
For i = 1 To lTableCount
Set objTable = objWordDocument.Tables(i)
objTable.Range.Copy
Set objExcelWorksheet = objExcelWorkbook.Sheets(i)
objExcelWorksheet.Paste
objExcelWorksheet.Columns.AutoFit
Next
Else
'If there is only one table
'Just copy it into the first worksheet
Set objTable = objWordDocument.Tables(1)
objTable.Range.Copy
Set objExcelWorksheet = objExcelWorkbook.Sheets(1)
objExcelWorksheet.Paste
objExcelWorksheet.Columns.AutoFit
End If
End Sub
.....Below macro just take the table in excel
Macro for picking up for one email :
Sub ExportTablesinEmailtoExcel()
Dim objMail As Outlook.MailItem
Dim objWordDocument As Word.Document
Dim objTable As Word.Table
Dim lTableCount As Long
Dim objExcelApp As Excel.Application
Dim objExcelWorkbook As Excel.Workbook
Dim objExcelWorksheet As Excel.Worksheet
Dim i As Long
'Create a new excel workbook
Set objExcelApp = CreateObject("Excel.Application")
Set objExcelWorkbook = objExcelApp.Workbooks.Add
objExcelApp.Visible = True
'Get the table(s) in the selected email
Set objMail = Outlook.Application.ActiveExplorer.Selection.Item(1)
Set objWordDocument = objMail.GetInspector.WordEditor
lTableCount = objWordDocument.Tables.Count
If lTableCount > 1 Then
'If there is more than one table
'Copy each table into separate worksheet
For i = 1 To lTableCount
Set objTable = objWordDocument.Tables(i)
objTable.Range.Copy
Set objExcelWorksheet = objExcelWorkbook.Sheets(i)
objExcelWorksheet.Paste
objExcelWorksheet.Columns.AutoFit
Next
Else
'If there is only one table
'Just copy it into the first worksheet
Set objTable = objWordDocument.Tables(1)
objTable.Range.Copy
Set objExcelWorksheet = objExcelWorkbook.Sheets(1)
objExcelWorksheet.Paste
objExcelWorksheet.Columns.AutoFit
End If
End Sub