Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
help please what am i doing wrong? | Excel Discussion (Misc queries) | |||
Insert Calculated Field (wrong Qty*Price = wrong Amount) | Excel Discussion (Misc queries) | |||
What Am I Doing Wrong | Excel Discussion (Misc queries) | |||
What am I doing wrong? | Excel Worksheet Functions | |||
Where am I going wrong? | Excel Discussion (Misc queries) |