I can't see why, but renaming files with name is not working when using variables ?
1. He recognise the files, because he does an import.
2. While testing and hard coding the names of the directory he's perform the renaming. See below in remarks.
Dim targetfilename As String
Dim lengte As Integer
strFileName = CStr(x)
MsgBox "strFilename :" & strFileName
lengte = Len(strFileName) - 3
MsgBox "lengte :" & lengte
targetfilename = Left(strFileName, lengte) & "txt"
MsgBox "targetfilename : " & targetfilename
'tested and ok : strFileName = "C:\Import\00017169.cmd"
'tested and ok : targetfilename = "C:\Import\00017169.txt"
Name strFileName As targetfilename 'renaming the files
strFileName = ""
targetfilename = ""
next i
1. He recognise the files, because he does an import.
2. While testing and hard coding the names of the directory he's perform the renaming. See below in remarks.
Dim targetfilename As String
Dim lengte As Integer
strFileName = CStr(x)
MsgBox "strFilename :" & strFileName
lengte = Len(strFileName) - 3
MsgBox "lengte :" & lengte
targetfilename = Left(strFileName, lengte) & "txt"
MsgBox "targetfilename : " & targetfilename
'tested and ok : strFileName = "C:\Import\00017169.cmd"
'tested and ok : targetfilename = "C:\Import\00017169.txt"
Name strFileName As targetfilename 'renaming the files
strFileName = ""
targetfilename = ""
next i