06-12-2013, 01:22 PM
I am trying to copy a folder using FSO in vb using below code :
With this code MsgBox doesnt show up, but the folder is copied successfully. But if I move the MsgBox statement outside the If segment, then it shows correctly.
Someone please explain this behavior.
Code:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
FSO.CopyFolder "C:\Program Files\Test", "E:\Test"
If err.number <> 0 Then
FSO.CreateFolder "E:\Test"
FSO.CopyFolder "C:\Program Files\Test", "E:\Test"
MsgBox "Folder Copied"
End If
With this code MsgBox doesnt show up, but the folder is copied successfully. But if I move the MsgBox statement outside the If segment, then it shows correctly.
Code:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
FSO.CopyFolder "C:\Program Files\Test", "E:\Test"
If err.number <> 0 Then
FSO.CreateFolder "E:\Test"
FSO.CopyFolder "C:\Program Files\Test", "E:\Test"
End If
MsgBox "Folder Copied"
Someone please explain this behavior.