Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm having problem with FileCopy could anyone help

Status
Not open for further replies.

tbscmgi

MIS
Sep 17, 2003
66
US

Sub ShowFileCopy
FCF = "A:\incoming.* "
FCT = "P:\fedin_" & time & "_" & date & ".txt"
FSO.CopyFile FCF , FCT , OverwriteExisting
End Sub

Thanks
Tony
 
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]
 
PHV types much faster than I. :)

[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.

Thanks for any help you can give.
Tony
 
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]
 
Hello tbscmgi,

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

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top