hi , i am extracting a table from outlook. my code works fine but i just want to extract the 2nd row of data onwards. the reason for this is i dont need the whole table all i need is the data; hence the first row which contain the header is not needed. i am not sure how abt to do this ? any advice would be greatly appreciated. my codes are as followed :
Sub getTableDataFromAccess()
Dim msg As Outlook.MailItem '
Dim i As Integer '
Dim j As Integer '
' ** requires project reference to Microsoft HTML Object Library
Dim webMsg As MSHTML.HTMLDocument '
Dim htable As MSHTML.HTMLTable '
Dim hrow As MSHTML.HTMLTableRow '
Dim hcell As MSHTML.HTMLTableCell '
Dim colTables As MSHTML.IHTMLElementCollection '
Dim colRows As MSHTML.IHTMLElementCollection '
Dim colCells As MSHTML.IHTMLElementCollection '
' ** requires project reference to Microsoft Excel library
Dim exc As Excel.Application '
Dim wb As Excel.Workbook '
Dim ws As Excel.Worksheet '
Set exc = CreateObject("Excel.Application")
Set wb = exc.Workbooks.Add '
Set ws = wb.Sheets(1) '
Set webMsg = Application.ActiveInspector.HTMLEditor
Set colTables = webMsg.getElementsByTagName("table")
Set htable = colTables.Item(, 1)
Set colRows = htable.rows
For Each hrow In colRows
i = hrow.RowIndex + 3 ' 4 is offset, change as needed to' adjust the blank rows at the top in EXCEL
Set colCells = hrow.cells
For Each hcell In colCells
j = hcell.cellIndex + 1
ws.cells(i, j) = Trim(hcell.innerText)
Next
Next
exc.Visible = True
ws.Activate
End Sub
Sub getTableDataFromAccess()
Dim msg As Outlook.MailItem '
Dim i As Integer '
Dim j As Integer '
' ** requires project reference to Microsoft HTML Object Library
Dim webMsg As MSHTML.HTMLDocument '
Dim htable As MSHTML.HTMLTable '
Dim hrow As MSHTML.HTMLTableRow '
Dim hcell As MSHTML.HTMLTableCell '
Dim colTables As MSHTML.IHTMLElementCollection '
Dim colRows As MSHTML.IHTMLElementCollection '
Dim colCells As MSHTML.IHTMLElementCollection '
' ** requires project reference to Microsoft Excel library
Dim exc As Excel.Application '
Dim wb As Excel.Workbook '
Dim ws As Excel.Worksheet '
Set exc = CreateObject("Excel.Application")
Set wb = exc.Workbooks.Add '
Set ws = wb.Sheets(1) '
Set webMsg = Application.ActiveInspector.HTMLEditor
Set colTables = webMsg.getElementsByTagName("table")
Set htable = colTables.Item(, 1)
Set colRows = htable.rows
For Each hrow In colRows
i = hrow.RowIndex + 3 ' 4 is offset, change as needed to' adjust the blank rows at the top in EXCEL
Set colCells = hrow.cells
For Each hcell In colCells
j = hcell.cellIndex + 1
ws.cells(i, j) = Trim(hcell.innerText)
Next
Next
exc.Visible = True
ws.Activate
End Sub