SetSourceData Error 1004 after certain number of times being called RRS feed

  • Pregunta

  • Hi all,

    I have a problem with an application created in Excel 2003. The application works fine in Excel 2003 but when it is executed in Office 2010 or 2013 the following problem occurs: I get the error message SetSourceData to object _Chart failedn1004 after calling the SetSourceData to pass a Range to a Chart a number of times.

    To find out more about the problem I have created a Sub in Excel VBA to pass a Range of values to a Chart using SetSourceData. This is executed within a For Loop where I repeat the SetSourceData instruction a number of times to determine when it crashes.

    Sub sendData()
        Dim cht As ChartObject
        Set cht = ActiveSheet.ChartObjects("Chart 16")
        On Error GoTo delSeries:
        For i = 0 To 10000
            cht.Chart.SetSourceData Source:=ActiveSheet.Range("A1:FA6")
        Next i
    Exit Sub
        For Each s In cht.Chart.SeriesCollection
        Next s
        Resume Next
    End Sub

    The Chart Object is a Chart I have already created in the WorkSheet and the values of the Range are generated using RANDBETWEEN formula.

    Could you please provide me with any ideas or a reason to understand why the application fails in Office 2010 and not in 2003? Any documentation to better understand the changes between versions?

    Many thanks for your help.


    miércoles, 22 de octubre de 2014 13:22