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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| Sub RemplirInfo()
Dim Ligne As Integer
Ligne = 2
While Cells(Ligne, 1) <> ""
Cells(Ligne, 2) = RechercheInfo(Cells(Ligne, 1))
Ligne = Ligne + 1
Wend
End Sub
Function RechercheInfo(Siren As String) As String
Dim Feuille As Worksheet, Cellule As Range
' Valeur de retour par défaut
RechercheInfo = "Je n'ai rien trouvé"
' Destruction de l'onglet "Temp" s'il existe
For Each Feuille In ActiveWorkbook.Sheets
If Feuille.Name = "Temp" Then
Application.DisplayAlerts = False ' Pour éviter le message de confirmation de destruction
Sheets("Temp").Delete
Application.DisplayAlerts = True
Exit For
End If
Next Feuille
' Creation de la feuille temporaire
Sheets.Add.Name = "Temp"
Sheets("Feuil1").Activate
' Creation de la connexion Web
With Sheets("Temp")
With .QueryTables.Add(Connection:= _
"URL;http://www.societe.com/cgi-bin/mainsrch/?champ=" & Siren, Destination _
:=Sheets("Temp").Cells(1, 1))
.Name = Siren
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
' Recherche des décisions de justice
Set Cellule = .Cells.Find(What:="Décision de justice", After:=.Cells(1, 1), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
If Cellule Is Nothing Then
RechercheInfo = "Pas de décision de justice"
Else
RechercheInfo = Cellule.Value
End If
' Recherche des entreprises radiées
Set Cellule = .Cells.Find(What:="Entreprise radiée", After:=.Cells(1, 1), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
If Not Cellule Is Nothing Then
RechercheInfo = RechercheInfo & " [" & Cellule.Value & "]"
End If
Set Cellule = Nothing
End With
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
End Function |
Partager