「activ」ではなく「active」という単語を検索するマクロを作成しましたが、フォルダ内の一部のファイル名に「activ」という単語が含まれている場合があります。これらを検索して名前を「アクティブ」に変更するマクロを作成して、残りのマクロが機能するようにします。私は少しずつ知っていますが、まともなコードをまとめることができないようです.
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
ループを挿入して、ファイルのリストを実行し、すべてのファイル名を検索する必要があります。
実際、私は解決策を見つけました:
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
ヘルプが必要な場合:
If strFile = "*activ*" Then
前に述べたように、ファイル名には「activ」だけでなく、「activcn」なども含まれます。