GeorgeEdward
Technical User
Hello
I am trying to walk through a directory structure and remove the apostrophe or single quote "'" character in folder names (not file names).
For example the folder "Budget's" would become "Budgets".
I am having trouble with the replace part of my code below! If you have any suggestions I would be most grateful.
Regards
GE
Sub FolderReplace1()
Dim strFolder As String
strFolder = Me.MainFolder
Call FolderReplace2(strFolder)
End Sub
Sub FolderReplace2(strFolder)
Dim fso As New FileSystemObject
Dim objSubFolders
Dim objFolder
Set objSubFolders = fso.GetFolder(strFolder).SubFolders
For Each objFolder In objSubFolders
fso.MoveFile objFolder.Path, Replace(objFolder.Path, Chr(39), Chr(32))
FolderReplace2 objFolder.Path
Next
Set fso = Nothing
End Sub
I am trying to walk through a directory structure and remove the apostrophe or single quote "'" character in folder names (not file names).
For example the folder "Budget's" would become "Budgets".
I am having trouble with the replace part of my code below! If you have any suggestions I would be most grateful.
Regards
GE
Sub FolderReplace1()
Dim strFolder As String
strFolder = Me.MainFolder
Call FolderReplace2(strFolder)
End Sub
Sub FolderReplace2(strFolder)
Dim fso As New FileSystemObject
Dim objSubFolders
Dim objFolder
Set objSubFolders = fso.GetFolder(strFolder).SubFolders
For Each objFolder In objSubFolders
fso.MoveFile objFolder.Path, Replace(objFolder.Path, Chr(39), Chr(32))
FolderReplace2 objFolder.Path
Next
Set fso = Nothing
End Sub