I'm having problem
Which problem ?
Any error message ? Unexpected behaviour ?
Anyway, when source contains wildcard characters it is assumed that destination is an existing folder in which to copy matching files.
Furthermore, the Time and Date functions returns values with illegal characters for file name.
Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
First, what is the specific problem or error you are having? Second, there are some errors in your code.
1) Unless FSO is declared globally, then you need to create the object in this sub.
2) Unless OverwriteExisting is declared globally, then you need to create the constant in this sub.
3) The way you have it written now, the sub will take all of the files on A: named incoming.something and rename them to the same name. Thus just the last one will actually be copied. All the rest will be overwritten. Unless the cpu's clock fortuitously changes minutes during the copy in which case you might end up with two files.
4) date returns a string that is '/' delimited. This will cause problems when you try to use it as the name of a file.
[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
Thanks for all of your help.
The date and time was extract and format as I needed, but the error that was coming up is path not found. I found out using a wildcard as part of the incoming file would not work with the current CopyFile statement.
I have an incoming file, but I don't know what is extension. How can I CopyFile this from point a to point b with point b having a different name.
So you have an incoming file that you know the first part of the name but not the extension? If this is the case, then I would get all of the files into a files collection then iterate through each one using InStr to see if the name is right. When you know the complete name. then copy thhe file using CopyFile.
[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
You just make it a variable fed into the sub. Though it is a variable (filespec), it does not mean it is undetermined. It is undetermined until the incoming file actually arrived, then it is completely determined.
Sub ShowFileCopy (filespec)
FCF = filespec
FCT = "P:\fedin_" & time & "_" & date & ".txt"
FSO.CopyFile FCF , FCT , OverwriteExisting
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.