1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub test_get_alt_img()
Set OITEM = ActiveInspector.CurrentItem
MsgBox get_alt_img(OITEM.HTMLBody)
End Sub
Function get_alt_img(html As String)
'---------------------------------------------------------------------------------------
' Procedure : get_alt_img
' Author : OCTU
' Date : 04/06/2015
' Purpose : trouve le premièr texte alternatif associé aux images
'---------------------------------------------------------------------------------------
'
Dim TableauIMG, TableauALT
TableauIMG = Split(html, "<img", , vbTextCompare)
For i = 1 To UBound(TableauIMG)
If InStr(1, TableauIMG(i), "alt=", vbTextCompare) > 0 Then
TableauALT = Split(TableauIMG(i), "alt=", , vbTextCompare)
OuFiniAlt = InStr(2, TableauALT(1), """", vbTextCompare)
If OuFiniAlt > 0 Then
alt = Mid(TableauALT(1), 2, OuFiniAlt - 2)
Exit For
End If
End If
Next i
get_alt_img = alt
End Function |
Partager