Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 10-06-2014, 06:15 AM
gmayor's Avatar
gmayor gmayor is offline copy content of a table inside email to excel sheet Windows 7 64bit copy content of a table inside email to excel sheet Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Back on the 28th September, I reported the imminent production of an add-in to do this. The add-in can now be found at http://www.gmayor.com/extract_email_data_addin.htm



Greg Maxey, with whom the add-in was developed, has his virtually identical version at http://gregmaxey.com/word_tip_pages/extract_outlook_data.html

These add-ins should work both with Office 2007 and 2013.

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #17  
Old 10-06-2014, 12:40 PM
megatronixs megatronixs is offline copy content of a table inside email to excel sheet Windows 7 32bit copy content of a table inside email to excel sheet Office 2003
Advanced Beginner
copy content of a table inside email to excel sheet
 
Join Date: Aug 2012
Posts: 42
megatronixs is on a distinguished road
Default

Hi,
Big thanks for the above links. In my case I will not be able to use it as I need to work with outlook 2003 and there are no other options than to find out why it is not working and fix it, other possibility I don't have.

Greetings and keep up the good work.
Reply With Quote
  #18  
Old 10-10-2014, 05:20 AM
megatronixs megatronixs is offline copy content of a table inside email to excel sheet Windows 7 32bit copy content of a table inside email to excel sheet Office 2003
Advanced Beginner
copy content of a table inside email to excel sheet
 
Join Date: Aug 2012
Posts: 42
megatronixs is on a distinguished road
Default

Hi Gmayor,

At the end I managed to solve it like this:

Code:
Public iItem As Integer
'Public Function FileExists(ByVal Filename As String) As Boolean
'
'Dim nAttr As Long
'
'On Error GoTo NoFile
'
'nAttr = GetAttr(Filename)
'
'If (nAttr And vbDirectory) <> vbDirectory Then
'
'FileExists = True
'
'End If
'
'NoFile:
'
'End Function
 
Sub ExtractData()
Dim oItem As MailItem
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox "No Items selected!", vbCritical, "Error"
Exit Sub
End If
For Each oItem In ActiveExplorer.Selection
If oItem.Subject = "New email received" Then
    CopyToExcel oItem
End If
Next oItem
Set oItem = Nothing
End Sub
Sub CopyToExcel(olItem As MailItem)
'Dim olItem As Outlook.MailItem
Dim xlApp As Object
Dim xlWB As Object
Dim xlSheet As Object
Dim vText As Variant
Dim sText As String
Dim sAddr As String
Dim vAddr As Variant
Dim vItem As Variant
Dim i As Long, j As Long
Dim rCount As Long
Dim bXStarted As Boolean
Dim FinalRow As Long
Dim strParameter As String
Dim strParamValue As String
Dim DateTime As String
Dim YourEmail As String
Const strWorkSheetName As String = "Data"
Const strWorkBookPath As String = "C:\"
Const strWorkBookName As String = "Data.xls"
'the path of the workbook
'Use FileExists function to determine the availability of the workbook
If Dir(strWorkBookPath & strWorkBookName) = "" Then Exit Sub
'Set olItem = Application.ActiveExplorer.Selection(iItem)
'Get Excel if it is running, or open it if not
On Error Resume Next
Set xlApp = GetObject("Excel.Application")
'Set xlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Set xlApp = CreateObject("Excel.Application")
bXStarted = True
End If
 
'Open the workbook to input the data
Set xlWB = xlApp.Workbooks(strWorkBookName)
If TypeName(xlWB) = "Nothing" Then
    Set xlWB = xlApp.Workbooks.Open(strWorkBookPath & strWorkBookName)
End If
Set xlSheet = xlWB.Sheets("Data")
'Process the message
With olItem
sText = olItem.Body
vText = Split(sText, Chr(13))
'Find the next empty line of the worksheet
FinalRow = xlSheet.Cells(xlSheet.Rows.Count, "B").End(xlUp).Row + 1
For i = UBound(vText) To 0 Step -1
 
    vItem = Split(vText(i), Chr(9))
 
    strParameter = ""
    strParamValue = ""
 
    strParameter = Trim(Replace(vItem(0), Chr(10), ""))
    strParamValue = Trim(vItem(1))
 
    Select Case strParameter
        Case "Time Submitted:"
            xlSheet.Range("B" & FinalRow) = strParamValue
            DateTime = strParamValue
        Case "Your name"
            xlSheet.Range("C" & FinalRow) = strParamValue
        Case "Your email"
            xlSheet.Range("D" & FinalRow) = strParamValue
            YourEmail = strParamValue
        Case "Team"
            xlSheet.Range("E" & FinalRow) = strParamValue
        Case "Your telephone number"
            xlSheet.Range("F" & FinalRow) = "'" & strParamValue
        Case "Field1?"
            xlSheet.Range("G" & FinalRow) = strParamValue
        Case "Field2?"
            xlSheet.Range("H" & FinalRow) = strParamValue
        Case "Field3?"
            xlSheet.Range("I" & FinalRow) = strParamValue
        Case "ThField4?"
            xlSheet.Range("J" & FinalRow) = strParamValue
        Case "Field5?"
            xlSheet.Range("K" & FinalRow) = strParamValue
        Case "Field6?"
            xlSheet.Range("L" & FinalRow) = strParamValue
    End Select
 
Next i
If xlApp.WorksheetFunction.CountIf(xlSheet.Range("A2:A10000"), DateTime & YourEmail) > 1 Then
    xlSheet.Range("B" & FinalRow & ":L" & FinalRow).ClearContents
Else
    xlWB.Save
End If
End With
 
xlWB.Close SaveChanges:=True
''
'If bXStarted Then
'
xlApp.Quit
'
'End If
 
Set xlApp = Nothing
 
Set xlWB = Nothing
 
Set xlSheet = Nothing
 
End Sub
What would be the easiest way to get this into an access database that has a table called Data with the same fields as above?

Greetings.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy all data from a website to excel sheet? Plz plz plz plz plz help...urgent Sam123 Excel 0 07-19-2014 02:12 AM
copy content of a table inside email to excel sheet Copy table content between documents mcb09 Word VBA 14 06-12-2014 09:33 PM
Copy content control entries to next table next page Mel_Herndon Word VBA 2 05-22-2014 05:07 PM
copy content of a table inside email to excel sheet Find Results in excel copy the rows to another sheet khalidfazeli Excel 2 02-06-2013 09:38 AM
How to Copy data from Outlook mail and Paste it in a Excel sheet? padhu1989 Outlook 0 09-11-2012 04:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:55 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft