Using vb script to copy one excel sheet to another is giving a macro error message
Posted on 2008-11-16
I'm using vb script to copy data from one excel sheet to another which seems to work, but when i try to open the newly created excel file i get the following error message -
Errors were detected in 'XXXX.xls,' but Microsoft Excel was able to open the file by making repairs listed below. Save the file to make these repairs permanent.
Lost Visual Basic project.
Lost ActiveX controls.
The vb script code that im using to copy the data between the 2 excel sheets is pretty basic -
Set objXL = CreateObject("EXCEL.APPLICATION")
Set objWS = objXL.ActiveWorkbook.Worksheets("Sheet1")
Set objWS2 = objXL.ActiveWorkbook.Worksheets("Sheet1")
objWS2.rows("1:1").value = objWS.Rows("1:1").value
When i try and copy the data manually it copies fine, and im able to open the new excel sheet without any errors, but when running my script it copies across the data fine but gives the above errors.
I think the issue has something to do with the fact that the first excel sheet has macros associated to it
Ideally i would like to run my script, have the data copied from one excel sheet to another, then open the new excel sheet without having to repair the excel because it contained the above errors.