Manzoor
Manzoor

Reputation: 13

VBA Run-time error on copying to csv

I am getting a run-time error on a copy method.

"Run-time error '-2147417848 (80010108)': Method 'Copy' of object 'Range' failed"

Sub SaveCSV()

    Worksheets("export").Copy
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\export.csv", FileFormat:=xlCSV
    ActiveWorkbook.Close
    Windows("exportData.xlsm").Activate
    Application.DisplayAlerts = True

    Application.OnTime Now + TimeValue("00:00:60"), "SaveCSV"

End Sub

but when I debug it shows that Worksheets("export").Copy

Upvotes: 0

Views: 238

Answers (1)

Excel Hero
Excel Hero

Reputation: 14754

There was a February 2015 security update to Excel 2010 that causes this problem when copying whole worksheets. Removing the update can fix the problem.

This is the link: MS15-012

On that page you will see that there is another update that may fix this problem. This is the link to that update: KB2956084

So you can try the 'fix' or uninstall the offending security update.

Upvotes: 1

Related Questions