Hi
I receive a lot of emials.
That i Want is identify a html format, to export valules that comes into a table, to a excel application, automatically.
I am running this script like a rule.
The problem is that my initial scrpit, not function when the table into email with html format, comes in a different position, because i am reading it like a text format.
I tried to change especial characters like vbCrLf by ";", but if the table change the position, i could not find the values at the same position.
I appreciated your comments, I want to read this email like a html format, to identify the tags.
Sub GetData()
Dim msg As Outlook.MailItem
Dim rows As Variant
Dim numberofColumns As Long
Dim numberofRows As Long
Dim headerValues As Variant
Dim headerRow() As String
Dim data() As String
Dim i As Long, k As Long, j As Long
Dim cont As String
Dim Val As String
Dim myXLApp As Excel.Application
Dim myXLWB As Excel.Workbook
Dim Asunto As String
Dim TotalRows As Integer
Dim objRegExp As RegExp
Dim objMatch As Match
Dim colMatches As MatchCollection
Dim RetStr As String
Dim cadena As String
Dim Ncadena As String
Dim myPattern As String
Set msg = ActiveExplorer.Selection.item(1)
Set myXLApp = New Excel.Application
myXLApp.Visible = True
Set myXLWB = myXLApp.Workbooks.Open("D:\ibague_sigma\UMTS\ControlIncidenciasUmts.xls")
'Val= "<table[^>] >.+</table>"
'Val= "<tr[^>] >.+</tr>"
'Val= "<td[^>] >.+</td>"
'Val = Chr(13) & Chr(10) & " "
msg.Body = Replace(msg.Body, vbCrLf, ";")
Set objRegExp = New RegExp
objRegExp.Pattern = ";+"
objRegExp.IgnoreCase = True
objRegExp.Global = True
'msg.Body
If (objRegExp.Test(msg.Body) = True) Then
MsgBox objRegExp.Replace(msg.Body, ";")
msg.Body = msg.Body & vbCrLf & objRegExp.Replace(msg.Body, ";")
rows = Split(objRegExp.Replace(msg.Body, ";"), ";")
End If
'La última
TotalRows = Sheets(1).Range("A65536").End(xlUp).Row
j = TotalRows + 1
Asunto = msg.Subject
For i = LBound(rows) To UBound(rows)
MsgBox rows(i)
cont = cont & vbCrLf & i & ";" & rows(i)
MsgBox cont
Next
With myXLWB.Worksheets(1)
.cells(j, 1).Value = Asunto
.cells(j, 2).Value = rows(2)
.cells(j, 3).Value = rows(6)
.cells(j, 4).Value = rows(9)
.cells(j, 5).Value = rows(10)
.cells(j, 6).Value = rows(17)
.cells(j, 7).Value = rows(23)
.cells(j, 8).Value = rows(27)
.cells(j, 9).Value = rows(31)
.cells(j, 10).Value = rows(36)
.cells(j, 11).Value = rows(40)
.cells(j, 12).Value = rows(48)
.cells(j, 13).Value = rows(54)
.cells(j, 14).Value = rows(60)
.cells(j, 15).Value = rows(66)
.cells(j, 16).Value = rows(72)
.cells(j, 17).Value = rows(78)
.cells(j, 18).Value = rows(84)
.cells(j, 19).Value = rows(90)
End With
msg.Body = cont
myXLWB.Save
myXLWB.Close
End Sub
thanks a lot
Malpa