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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Public mot As String
Public nomFichier As String
Function opened_file() As String
'ouverture des fichiers excel
opened_file_data = Application.GetOpenFilename()
If opened_file_data = False Then
MsgBox ("File not selected, the program is turning off.")
End
Else
opened_file = opened_file_data ' W:\bibi\hola.xlsx
Open opened_file_data For Input As #1 '-------------------
End If
End Function
Public Sub Search_titre()
opened_file ' ------------------
chaineCherche = "HREF="""
'chaineCherche = "TITLE>"
p = 1
i = 1
position_avancement = 1
Do While Not EOF(1)
Line Input #1, strline
Sheets(2).Cells(1, i) = strline
'On récupère la position de départ de la chaine de texte
position = InStr(position_avancement, strline, chaineCherche, vbTextCompare)
position_fin = InStr(position + 1, strline, """>", vbTextCompare)
If (position > 0) Then
ThisWorkbook.Activate
Sheets(1).Cells(1, i) = Mid(strline, position + Len(chaineCherche), position_fin - position - Len(chaineCherche))
' Xpath : //*[starts-with(name(),'PSL')]
i = i + 1
position = position_fin
End If
MsgBox (position & position_fin)
Loop 'Until EOF(1)
Close #1
End Sub |
Partager