Good morning,
The purpose of the code below is to swap the name of a file AAAA - BBB to BBB - AAAA.
The problem is that there is a blank character in front of BBB after permutation.
Could someone advise me?
Thank you in advance.
Habiler
Sub Perm_Mat_Name() Dim OldFolderName, NewFolderName As String Dim objFileSystem As Object Dim newName As String Dim newNameSplit As String Dim splitMatrNom() As String Set objFSO = New FileSystemObject Set mysource = objFSO.GetFolder("C:\PERS") Set objFileSystem = CreateObject("Scripting.FileSystemObject") Dim i As Long For Each Folder In mysource.SubFolders splitMatrNom = Split(Folder.Name, "-") ' Debug.Print splitMatrNom(1) 'For i = LBound(splitMatrNom) To UBound(splitMatrNom) newNameSplit = splitMatrNom(1) & " - " & splitMatrNom(0) Debug.Print newNameSplit If Folder.Name <> newName Then Folder.Name = newNameSplit 'Next i Next Folder End Sub
Bookmarks