I have written a macro that looks for the word "active" rather than "activ" but some of the filenames in my folder may contain the word "activ". I want to write a macro to search for these and rename them as "active" so the rest of my macro works. i know bits and pieces but can't seem to put a decent code together.
If FileName = "*activ*" then
'also the file name is not just "activ" it maybe "activcn".
'am i doing this right by putting the **?
FileName = replace(FileName, "activ", "active")
Else
End if
and I need to put a loop in so it runs through the list of files and searches all filenames.
Actually I've found a solution:
Dim strFile As String
Dim newPath As String
newPath = "S:\test\"
strFile = Dir(newPath & "*.*")
If strFile = "*activ*" Then
Do While Len(strFile) > 0
If InStr(strFile, "activ") > 0 Then
Name strFolder & strFile As strFolder & replace(strFile, "activ", "active")
End If
strFile = Dir()
Loop
Else
End If
Just need help with:
If strFile = "*activ*" Then
As I said earlier, the filename contains more than just "activ" e.g. "activcn".