I m using xcopy cmd in vba i have to check it copied properl

January 3, 2014 at 03:55:55
Specs: Windows 7, core 2 duo
how to check whether the xcopy command copied all the files or any error occured.Please help me it wouble be appreciated

See More: I m using xcopy cmd in vba i have to check it copied properl

Report •


#1
January 3, 2014 at 03:58:55
Check the error code returned by xcode. http://www.microsoft.com/resources/...

Report •

#2
January 3, 2014 at 07:00:09
Hi Thank you so much for your reply but i am using writeline function to write content in the bat file. can you please help me how do i use this here is my code
dim retval
for i=2 to 5
filepath = "C:\Windows\336.bat"
file.WriteLine "MkDir " & folder
file.WriteLine "XCOPY " & path & " " & folder & " /SEY"
next
retval=shell(filepath)
i want to get the status of each copy statement
I dont know how to use the variable Errorlevel it shows some Type mismatch error

message edited by EsakkiKarthi


Report •

#3
January 3, 2014 at 07:28:30
So you are only using VBA to construct a batch file, and then you run the batch file? Well the link I gave gives you an example of what the batch file needs to look like. So you need to arrange for VBA to create a batch file that looks something like that one.

Report •

Related Solutions

#4
January 3, 2014 at 07:35:24
yes you are right.i have tried to get the error level but i didnt get any value is there any prgm example to use the errorlevel and xcopy cmd clearly
It is loading for long time then shows error no 75

Report •

#5
January 3, 2014 at 20:37:18
"file" and "path" are not assigned values in the code presented. That's one problem.

Next, the return-code will be only that of the batch "wrapper", not the individual operations initiated by it. The batchfile itself should handle the error reporting. Simplest method is to pipe error output of xcopy to a logfile:
file.WriteLine "XCOPY " & path & " " & folder & " /SEY 2>>xcerr.log"
but of course your batch could handle it other ways using errorlevel (from inside the batch, not your batch-creation code which is presenting problems anyway.)

message edited by nbrane


Report •

#6
January 5, 2014 at 08:25:28
Why are you writing a batch file to copy directories? VBA has access to Windows objects that can modify the directory structure natively. Specifically, FileSystemObject has a copy folder method, as does the Windows Shell.

How To Ask Questions The Smart Way


Report •


Ask Question