Hi,
I know this issue is posted before but I cannot find the solution.
I want to copy a sheet from an xls file into another. My codes are the following:
tempfile =“c:\wages\temp_wages.xls”
tempxls=Dir$(tempfile)
If tempxls=“” Then
Set tempExcel = Createobject(“Excel.Application”)
Set tempxlBook = tempExcel.Workbooks.Add()
Call tempxlBook.SaveAs(tempfile, -4143, “”, “”, False, False, 1)
Else
Set tempExcel = Createobject(“Excel.Application”)
Set tempxlBook = tempExcel.Workbooks.open(tempfile)
Set tempxlSheet = tempExcel.Worksheets.Add()
Call tempxlBook.Save
End If
Set tempExcel = Getobject(tempfile)
filename = “c:\wages"+Trim(Aempid(w))+”.xls"
xlsfile=Dir$(filename)
Set Excel = Createobject(“Excel.Application”)
Set xlBook = Excel.Workbooks.open(filename)
tempExcel.sheets(1).copy (Excel.sheets(1))
I get the error message “incorrect copy method”. I also tried:
tempExcel.sheets(1).copy Before:=Excel.sheets(1) and
tempExcel.sheets(1).copy (, Excel.sheets(1))
None of them works.
Can anyone help me?
Thank you very much.
Etyien