Visual Basic-运行时错误1004

时间:2016-02-23 17:04:10

标签: excel runtime

下面的Visual Basic代码考虑了我的Excel电子表格的所有图形中的新(最后)列。它在4个月内运行没有任何问题,现在没有改变任何东西,它不再起作用了,我在下面一行有“运行时错误1004”:

Rinitemp = workgraph.Chart.SeriesCollection(j).FormulaLocal

我一直在论坛上寻找这个错误,但每一次,它似乎都是出于一个非常不同的原因。经过几周的搜索,有人可以帮助我吗? 完整的代码是:

Sub Add_col()

    Dim Cible As ChartObject

    Dim i As Integer, j As Integer

    Dim Rinit, Rfinale As String

    Dim Rinitemp As String

    Dim FinPlageInit, FinPlageFinale As String

    FinPlageInit = "$BD"

    FinPlageFinale = "$BE"


    For Each Wb In Workbooks

        For Each ws In Wb.Worksheets

            For Each workgraph In ws.ChartObjects

                'For all series

                For j = 1 To workgraph.Chart.SeriesCollection.Count

                       Rinitemp = workgraph.Chart.SeriesCollection(j).FormulaLocal
                       Position_chaine_A_remplacer = InStr(Rinitemp, FinPlageInit)
                       LongueurChaine = Len(Rinitemp)
                       While Position_chaine_A_remplacer > 0
                           Rfinale = Mid(Rinitemp, 1, Position_chaine_A_remplacer - 1) _
                           & FinPlageFinale _
                           & Mid(Rinitemp, Position_chaine_A_remplacer + 3, LongueurChaine)
                           Rinitemp = Rfinale
                          Position_chaine_A_remplacer = InStr(Position_chaine_A_remplacer + 1, Rfinale,   FinPlageInit)
                          workgraph.Chart.SeriesCollection(j).FormulaLocal = Rfinale
                        Wend                  
                Next j
           Next workgraph
      Next ws
   Next Wb
End Sub

0 个答案:

没有答案