I am trying this code .vbs but am getting an error of "Copy Method of Class Worksheet failed". Existing File1 has two sheets called "Test1" and "Test 2" while File2 has two sheets called "Test3" and "Test4". However generically the number of sheets may be different with different names and it more the process of copying all over regardless of name.
Any help on what could be tweaked would be appreciated.
Dim eapp
Dim wkbk_from
Dim wkbk_to
Dim wksh
Dim J
Set eapp = CreateObject("Excel.Application")
Set wkbk_from = eapp.Workbooks.Open("D:\Excel_VB_Test\File2.xlsx")
Set wkbk_to = eapp.Workbooks.Open("D:\Excel_VB_Test\File1.xlsx")
eapp.Visible = true
For j = 1 to wkbk_from.Worksheets.count
wkbk_from.worksheets(j).Copy wkbk_to
Next
wkbk_to.SaveAs "NewFile.xlsx"
Any help on what could be tweaked would be appreciated.
Dim eapp
Dim wkbk_from
Dim wkbk_to
Dim wksh
Dim J
Set eapp = CreateObject("Excel.Application")
Set wkbk_from = eapp.Workbooks.Open("D:\Excel_VB_Test\File2.xlsx")
Set wkbk_to = eapp.Workbooks.Open("D:\Excel_VB_Test\File1.xlsx")
eapp.Visible = true
For j = 1 to wkbk_from.Worksheets.count
wkbk_from.worksheets(j).Copy wkbk_to
Next
wkbk_to.SaveAs "NewFile.xlsx"