hello,
I have this code that I'm trying to use but is not working, so I'm posting on here to see if someone can help me with how to fix the error. What the code is trying to do is to look in the subdirectory
D:\B D client data\H T\NewBusiness\
for a file that will have (a string of numbers) + (.txt) as it's file name and rename that file to HT012507.txt.
There is another file in the same directory named HT.txt that needs to be left alone and not renamed. These are the only two .txt files in the subdirectory.
Visual Basic is giving me the
Run-time error '52':
Bad file name or number
when I try to run the code, and stops on the Name line, so I'm assuming the SourceFile line is the problem.
Can anyone help me with what the syntax of the below code so it will work properly?
thanks in advance,
david
I have this code that I'm trying to use but is not working, so I'm posting on here to see if someone can help me with how to fix the error. What the code is trying to do is to look in the subdirectory
D:\B D client data\H T\NewBusiness\
for a file that will have (a string of numbers) + (.txt) as it's file name and rename that file to HT012507.txt.
There is another file in the same directory named HT.txt that needs to be left alone and not renamed. These are the only two .txt files in the subdirectory.
Visual Basic is giving me the
Run-time error '52':
Bad file name or number
when I try to run the code, and stops on the Name line, so I'm assuming the SourceFile line is the problem.
Can anyone help me with what the syntax of the below code so it will work properly?
thanks in advance,
david
Code:
Dim SourceFile, DestinationFile As String
SourceFile = "D:\B D client data\H T\NewBusiness\[1-9]*.txt"
DestinationFile = "D:\B D client data\H T\NewBusiness\HT" & Format(Date, "mmddyy") & ".txt"
Name SourceFile As DestinationFile