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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copie file based upon excel data

Status
Not open for further replies.

Nogi

Technical User
Dec 10, 2004
132
BE
I have a question regarding a script i would like to use, but i have no idea if it can be accomplished.

Maybe one of you scripting experts could tell me straight away wether this is worth searching for or not.

I'm looking for a script, that allows me to copy folders and their files from a server to a local, based upon the values of cells in an excel spreadsheet.

More in Detail:
All values in the excelsheet are mentioned under column B.
B1, B2, B3 etc.
All of the values represent a folder on a server.
Ex. cell B1 contains value S0003030 (folder S0003030 is on the server).

With a push on a button, i would like a script to run through all the values under column B, and copy their corresponding folders on the server to the same folder the excel sheet is in on the local computer.

Can this be done? I'm not a programmer, but maybe if somebody could push me in the right direction i can always try to get it fixed myself by searching a bit everywhere.

Thanks in advance
 
Sure, just do a search in Excel VBA help on "FileSystemObject". That will show you how to move, copy, create files and folders.

That should get you started.

Uncle Mike
 
ok thanks for your reply.

In the mean while, i found this script:
Quote:

Sub copy_files()
Dim rng As Range
Dim cell As Range
Dim path_src As String
Dim past_dest As String
Dim SrcFilename As String
Dim DestFilename As String

Set rng = Selection
path_src = Range("B1").Value
path_dest = Range("C1").Value
For Each cell In rng
SrcFilename = "C:\Blue Books\Start Project" & cell.Value
DestFilename = "C:\Documents and Settings\rl\My Documents\New Blue Book\Partitions" & cell.Value
FileCopy SrcFilename, DestFilename
Next
End Sub

Unquote

i receive an "error 97" - path not found error, marking the lign "FileCopy SrcFilename, DestFilename" of the script.
The path i use in the script i have already checked and is correct.
Has anyone have an idea maybe of what could cause this?
 
Possibly you are missing "\" between the paths and the file name.

 
Yeah, found out that it doesn't really satisfy my needs as this script handles files, not folders.

I really gotta search for a fso thing combined with the FileSystemObject as you previously recommended.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top