1

What we are trying to achieve: To read directory paths from an XML file and perform a copy and paste operation. The script works if we remove the last line: fso.CopyFolder Directory, t. But it fails when we keep this line. The script is able to read the values from the XML file.

Error occurs at line no: 19

i.e.: For each child in objRoot.childNodes, saying “Object Required”

Option Explicit
set fso = CreateObject("Scripting.FileSystemObject")
dim fso, objDoc, objRoot, child, s, t, WshShell, filesys, ObjShell,objDox

Set objDoc = CreateObject("MSXML.DOMDocument")
objDoc.Async = False
objDoc.Load "location.xml"
objDoc.validateOnParse=False
Set objRoot = objDoc.documentElement
Dim CurrentDirectory, Directory
    CurrentDirectory = fso.GetAbsolutePathName(".")
For Each child in objRoot.childNodes
   s = child.getAttribute("Source")
   t = child.getAttribute("Destination")
   Directory = CurrentDirectory & "\" & s
Next

fso.CopyFolder Directory, t
zx485
  • 28,498
  • 28
  • 50
  • 59
Mansing
  • 11
  • 1

1 Answers1

0

Try Changing

fso.CopyFolder Directory, t

to

fso.CopyFolder Directory, t & "\"

because when copying or moving to a folder you have to end the destination folder with a "\"

Ronnie Matthews
  • 473
  • 4
  • 13