none
Run-time error '2147467259 (80004005)': Method 'InvertIfNegative' of object 'Series' failed RRS feed

  • Question

  • Hello,

    My master excel file runs a macro to save multiple excel files that contain graphics. I've added this sub to the macro to correct the invert if negative issue (the sub is added in a module with the main macro):

    Sub Invertrednegative()
    
    Dim sht As Worksheet
    Dim Cht As ChartObject
    Dim sr As Series
    
    For Each sht In ActiveWorkbook.Worksheets
          For Each Cht In sht.ChartObjects
            For Each sr In Cht.Chart.SeriesCollection
                sr.InvertIfNegative = True
                sr.InvertColor = vbRed
            Next
          Next
        Next
    End Sub

    To correct the graphs automatically, I've programmed this when the master file opens and it's working correctly at this point:

    Private Sub Workbook_Open()
    
    Run "Invertrednegative"
    
    End Sub

    My issue occurs when I want to open the new excel files created by the main macro. The Workbook Open (in This Worbook) and Module containing the main macro are transferred in the new files. Anyone have an idea why I get the run-time error in the title? The error message is for this line in the sub: sr.InvertIfNegative = True

    Anyone have an idea why the files are "bugging"?

    Thanks!

    

    

    

    Monday, June 15, 2015 7:53 PM

All replies

  • I don't really know what you mean by "The Workbook Open (in This Worbook) and Module containing the main macro are transferred in the new files."

    I suggest that if the code is running for the first workbook that is opened then perhaps the correct workbook is not being referenced with the remaining workbooks when opened. Can you post the code that opens the remaining workbooks.


    Regards, OssieMac

    Monday, June 15, 2015 8:47 PM
  • Thanks OssieMac

    What I mean is that in VBA the coding entered when opening the workbook is in the section Microsoft Excel Objects (This Workbook). The macro running everything is entered in a Module that I inserted.

    When the macro copies the new workbooks, everything is transferred / the same in the new workbooks. I'm not coding anything to open workbooks automatically because they will be opened by many people at different times.

    Is this clearer?

    thanks again!  

    Wednesday, June 17, 2015 7:11 PM