Un peu plus propre encore
Option Explicit 'Module 2 import contacts vCard v3.0
Public F1 As Worksheet
Sub Import_vCard()
Dim ChemDossier As String, ligne As String, S1() As String, S2() As String, List_vcf() As String, Fichier As String, n_fichier2 As String
Dim i As Integer, f As Integer, Id As Integer, nbtel As Integer, derlig As Integer, num_fichier As Integer
ChemDossier = ChoixDossier
If Not ChemDossier = "" Then
Fichier = Dir(ChemDossier & "\*.vcf")
If Fichier = "" Then
MsgBox "Pas de fichier vCard dans ce dossier !", vbExclamation, "OUPS ..."
Exit Sub
End If
Do
i = i + 1
ReDim Preserve List_vcf(1 To i)
List_vcf(i) = Fichier
Fichier = Dir
Loop Until Fichier = ""
Id = Application.Max(Sheets("Data1").Range("A:A"))
nbtel = 0
For i = 1 To UBound(List_vcf)
derlig = Cells(Rows.Count, "V").End(xlUp).Row + 1
f = FreeFile
Open ChemDossier & "\" & List_vcf(i) For Input As f
While Not EOF(f)
Line Input #f, ligne
If Len(ligne) > 0 Then
S1 = Split(ligne, ":")
Select Case UCase(Left(S1(0), 3))
Case "NOT"
Cells(derlig, "V") = correction(S1(1)) ' Note
End Select
If InStr(ligne, ":") = 0 Then Cells(derlig, "V") = Cells(derlig, "V") & correction(ligne)
End If
Wend
Close f
Next i
If i = 0 Then Exit Sub
End If
Cells.EntireRow.AutoFit
If i > 1 Then MsgBox " " & i - 1 & " contact(s) vCard ajouté(s)." & Chr(10) & Chr(10) & "", vbInformation, "Import vCard"
End Sub
' Code SilkyRoad
Function ChoixDossier() As String
Dim Dossier As FileDialog
Set Dossier = Application.FileDialog(msoFileDialogFolderPicker)
Dossier.Show
On Error GoTo errhdlr
ChoixDossier = Dossier.SelectedItems(1)
Exit Function
errhdlr:
ChoixDossier = ""
End Function
Function correction(texte As String)
correction = texte
correction = Replace(correction, "ç", "ç")
correction = Replace(correction, "à¨", "è")
correction = Replace(correction, "è", "è")
correction = Replace(correction, "é", "é")
correction = Replace(correction, "â", "â")
correction = Replace(correction, "Ã", "à")
correction = Replace(correction, " à ", " à ")
correction = Replace(correction, " à ", " à ")
correction = Replace(correction, " Â ", " ")
correction = Replace(correction, " à Â", " à ")
correction = Replace(correction, " Ã Â ", " à ")
correction = Replace(correction, " Ã Â ", " à ")
correction = Replace(correction, " Ã Â ", " à ")
correction = Replace(correction, " à ", " à ")
correction = Replace(correction, " à‚Â ", "")
correction = Replace(correction, "à‹", "Ë")
correction = Replace(correction, "à¢", "â")
correction = Replace(correction, "à®", "î")
correction = Replace(correction, "à´", "ô")
correction = Replace(correction, "àª", "ê")
correction = Replace(correction, "’", "'")
correction = Replace(correction, "\,", ",")
correction = Replace(correction, "\", ", ")
correction = Replace(correction, " http //", "http://")
correction = Replace(correction, " https //", "https://")
correction = Replace(correction, ",", "")
correction = Replace(correction, ".", "")
correction = Replace(correction, " , ", "")
correction = Replace(correction, "m²", "m²")
correction = Replace(correction, "/", "-")
End Function
Pour les autres champs, ils étaient tous inhibés dans ta macro.
Il faudrait me donner la correspondance entre le code de la VCARD et la colonne de la feuille.
Dans tous les cas, le sujet posté est lui résolu puisqu'il s'agissait d'importer plusieurs lignes dans la même cellule.
edit : suppression du fichier pour ne garder que le dernier du fil