Where am I going wrong with this?

H

harg7769

Having read through the messages on the NG, I thought that the sub
below did something very similar to what i needed, and so added it to
my procedure.

What I have is a proc that imports all the xls files in a specified
folder before renaming the file as a CSV file in preparation for
import to a DOS database. Everything works great on it, so I thought I
would get the proc to move the files from the holding folder to the
imported folder.

As the import procedure loops through each of the XLS files in the
folder, I wanted to call the demo proc, and move the files as it goes.

I ran it and had a look at the k:\bgas folder - nothing in there so it
must have worked. Except it hasn't. The files haven't appeared in the
ToFolder.

I put a MsgBox in the proc to see what it was passing and it all looks
ok to me, as the correct file name is passed each time, but obviously
I have done something wrong. Any suggestions welcome.

regards

Andrew H


Sub Demo(FNames)
Dim FromFolder As String
Dim ToFolder As String

FromFolder = "K:\BGAS\" & FNames
ToFolder = "K:\BGAS\IMPORTED"

On Error Resume Next
With CreateObject("Scripting.FileSystemObject")
.CopyFile FromFolder, ToFolder, True
.DeleteFile FromFolder, True
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top