bonjour à tous
j'ai une routine qui énumère TOUS les élément d'un dossier (== sous dossiers & fichiers) qui fonctionne parfaitement.
SAUF avec certains noms reçus de l'extérieur par mail.
On pense à un problème de codage ASCI, effectivement.
MAIS ces caractères inhabituels n'apparaissent PAS dans l'explorateur (W7 pro)
ex dans EXPLORER j'ai:
mais quand je corrige le à qui semble normal: curseur après le à et EFFACEMENT j’obtiens 2a !:
effectivement quand je copie le nom original & le nom corrigé à la main, on a APPAREMMENT la même chose:
1 2
| Documents à fournir.pdf
Documents à fournir.pdf |
Mais quand je copie les 2 dans notepad & que je traduis en HEXA, j'ai:
1 2
| Documents 61CC80 fournir.pdf
Documents C3A0 fournir.pdf |
ET VBA ne comprend pas puisque lui il interprète comme:
: fullFilePath : "L:\ap2\Downloads\Documents a` fournir.pdf" : String
ci joint le code de listage des répertoires:
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
| Sub LoopAllSubFolders(ByVal folderPath As String)
Dim fileName As String
Dim fullFilePath As String
Dim numFolders As Long
Dim folders() As String
Dim i As Long
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
fileName = Dir(folderPath & "*.*", vbDirectory)
While Len(fileName) <> 0
If Left(fileName, 1) <> "." Then
fullFilePath = folderPath & fileName
If (GetAttr(fullFilePath) And vbDirectory) = vbDirectory Then
ReDim Preserve folders(0 To numFolders) As String
folders(numFolders) = fullFilePath
numFolders = numFolders + 1
Else
'Insert the actions to be performed on each file
'This example will print the full file path to the immediate window
Debug.Print folderPath & fileName
End If
End If
fileName = Dir()
Wend
For i = 0 To numFolders - 1
LoopAllSubFolders folders(i)
Next i
End Sub |
ça bloque à:
If (GetAttr(fullFilePath) And vbDirectory) = vbDirectory Then
puisque on a:
: fullFilePath : "L:\ap2\Downloads\Documents a` fournir.pdf" : String
Il y a t il a un moyen de corriger cela ?
Merci à tous
Partager