ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Where am I going wrong with this? (https://www.excelbanter.com/excel-programming/299429-where-am-i-going-wrong.html)

[email protected]

Where am I going wrong with this?
 
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

Jimbo McCray

Where am I going wrong with this?
 
Add a backslash after "IMPORTED" and see how that works.
Jim
-----Original Message-----
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
.



All times are GMT +1. The time now is 11:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com