VBScript to create an Excel in one folder and paste into another folder
kw.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("D:\VBScript\Excel1") Then
    objFSO.DeleteFolder("D:\VBScript\Excel1")
Else
    Set objFolder1 = objFSO.CreateFolder("D:\VBScript\Excel1")
End If

Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = True
objExcel.Workbooks.Add
objExcel.ActiveWorkbook.SaveAs "D:\VBScript\Excel1\Trial.xlsx"
objExcel.Application.Quit

If objFSO.FolderExists("D:\VBScript\Excel2") Then
    objFSO.DeleteFolder("D:\VBScript\Excel2")
Else
    Set objFolder2 = objFSO.CreateFolder("D:\VBScript\Excel2")
End If

objFSO.CopyFile "D:\VBScript\Excel1\Trial.xlsx","D:\VBScript\Excel2\",True
print "File copied successfully!"
Output

File copied successfully!

Advertisement