Pick up tables in the email from and paste in Excel for multiple emails

abdulads

Board Regular
Joined
Dec 22, 2013
Messages
81
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
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,215,461
Messages
6,124,958
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top