copying folder contents

J

jnewl

i based the following code on an example from copy files to other folder,
recorded march 31, 2006

Sub copyfolder_con()
Dim strfom, strto As String
Dim copyinfo As Object

strfrom = "w:\adhoc \ ipa profiles \ 2006 \ power play reports for ipas \
nnyppo power play reports\ *.xls"
MsgBox strfrom
strto = "w:\adhoc \ ipa profiles \ 2006 \ test area"
MsgBox strto
Set copyinfo = CreateObject("scripting.FileSystemObject")

copyinfo.copyfile strfrom, strto, False

End Sub


strfrom and strto have valid values.

it always abends at the copyinfo.copyfile statement.

yet this is exactly what is in help and what was on for march 31.

so why the abends?

thanks
 
R

Ron de Bruin

Hi jnewl

Try this to copy from C:\Data\*.* to C:\Paste

Sub test()
Dim objShell, objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Paste")

If (Not objFolder Is Nothing) Then
objFolder.CopyHere ("C:\Data\*.*")
End If

End Sub
 
J

jnewl

this did not help. got nothing after the execution of this code

the previous code gave the msg ' could not find the path', but the contents
for strfrom and strto were valid

Sub copyfolder_con()
'Dim strfom, strto As String
'Dim copyinfo As Object

'strfrom = "w:\adhoc \ ipa profiles \ 2006 \ power play reports for ipas \
nnyppo power play reports\ *.xls"

'strto = "w:\adhoc \ ipa profiles \ 2006 \ test area"

'Set copyinfo = CreateObject("scripting.FileSystemObject")

'copyinfo.copyfile strfrom, strto, False

Dim objshell, objfolder
Set objshell = CreateObject("shell.application")
Set objfolder = objshell.Namespace("w:\adhoc \ ipa profiles \ 2006 \ test
area")

If (Not objfolder Is Nothing) Then
objfolder.copyhere ("w:\adhoc \ ipa profiles \ 2006 \ power play reports
for ipas \ nnyppo power play reports\ *.*")
End If


End Sub
 
J

jnewl

if the spaces are there or not there, still get the same error msg. what is
such a puzzle, is that this code is like the code outlined in the march 31
response, yet does not work
 
R

Ron de Bruin

got nothing after the execution of this code

Then this path is not correct
"w:\adhoc \ ipa profiles \ 2006 \ test area"
go to the folder in Explorer and copy the path fron the address bar
 
J

jnewl

hi,
it was the from path that was wrong, there was a space after the last \
so it could not find *.*

thanks, for your help
 

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