Get table from lotus note email to excel cell

tommy8quko

New Member
Joined
Mar 27, 2017
Messages
18
hi guys,

I got trouble on handling the lotus notes and internet don't have much resources on this.
Here is my problem, i have a table in email look like below.
Code:

FoodDrinksPeopleCarTotal
1059125

<tbody>
</tbody>

And i got below code so far, but it error on Set rttab = rtnav.GetElement line.
Any idea how to do the things I want?
Thanks, i have been stuck for whole days.

Code:
Public Sub Get_Notes_Email_Text()


    Dim NSession As Object      'NotesSession
    Dim NMailDb As Object       'NotesDatabase
    Dim NDocs As Object         'NotesDocumentCollection
    Dim NDoc As Object          'NotesDocument
    Dim NNextDoc As Object      'NotesDocument
    Dim NItem As Object         'NotesItem
    Dim view As String
    Dim filterText As String
    
    view = "Bond IPO"       'Name of view or folder to retrieve documents from
    filterText = ActiveSheet.Range("AB8")    'Optional text string to filter the view
    
    Set NSession = CreateObject("Notes.NotesSession")
    Set NMailDb = NSession.GetDatabase("", "")  'Default server and database


    If Not NMailDb.IsOpen Then NMailDb.OpenMail
    
    Set NDocs = NMailDb.GetView(view)
    NDocs.Clear
        
    'Apply optional filter
        
    If filterText <> "" Then
        NDocs.FTSearch filterText, 0
    End If
      
    Set NDoc = NDocs.GetFirstDocument
    Do Until NDoc Is Nothing
        Set NNextDoc = NDocs.GetNextDocument(NDoc)
        Set NItem = NDoc.GetFirstItem("Body")
           Set rtnav = NItem.CreateNavigator
            Set rttab = rtnav.GetElement
            Set rtrange = NItem.CreateRange
        
        
        
        If Not NItem Is Nothing Then
            lines = Split(NItem.Text, vbCrLf)
                Range("A10").Resize(UBound(lines) + 1, 1).Value = Application.WorksheetFunction.Transpose(lines)
        End If
        Set NDoc = NNextDoc
    Loop
    
    NMailDb.Close
    NSession.Close
    
    Set NSession = Nothing


End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I think you have to set the Navigator position to an element (e.g. a table) before calling GetElement:

Code:
    Do Until NDoc Is Nothing
        Set NNextDoc = NDocs.GetNextDocument(NDoc)
        Set NItem = NDoc.GetFirstItem("Body")
        Set rtnav = NItem.CreateNavigator

        If rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
            Set rttab = rtnav.GetElement
            Set rtrange = NItem.CreateRange

            If Not NItem Is Nothing Then
                lines = Split(NItem.Text, vbCrLf)
                Range("A10").Resize(UBound(lines) + 1, 1).Value = Application.WorksheetFunction.Transpose(lines)
            End If
        Else
            MsgBox "No table in Body item"
        End If
    Loop
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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