I'm trying to run the below mentioned code in VB(Excel Macro) but i m stuck with an error which pops up on running saying "Automation Error".
strComputer = "."
Set objNetwork = CreateObject("Wscript.Network") Set fs = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='U:\'} Where " _ & "ResultClass = CIM_DataFile")
For Each objFile In colFiles if objFile.FileName = "ml_*" Then
destinationPROD = "X:\ABC\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
else
destinationPROD = "X:\PQR\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
End If
Next
Thanks in advance.Please help me