none
Excel 2003 vs 2010 vba chart compatibility RRS feed

  • Question

  • The following works in Excel 2003

       Sub applyChartStyles(c As Chart, idx As Integer, Optional applyChartType = True)

                                        .

                                        .

                                        .

       With [StyleIndex].Offset(0, idx - 1)

                                        .

                                        .

                                        .

            c.chartTitle.Font.Name = .Offset(tFONT)

            c.chartTitle.Font.Bold = .Offset(tBOLD)

            c.chartTitle.Font.Size = .Offset(tSIZE)

    In Excel 2010, the following doesn’t work:

       Sub applyChartStyles(c As Chart, idx As Integer, Optional applyChartType = True)

                                        .

                                        .

                                        .

        With [StyleIndex].Offset(0, idx - 1)

           c.chartTitle.Font.Name = .Offset(tFONT)                                                      Doesn’t work

    Dim aaa As Variant

            c.chartTitle.Font.Name = "Ariel"                                                                  Works

            aaa = [StyleIndex].Offset(tFONT, idx - 1)

            c.chartTitle.Font.Name = aaa                                                                       Works

            c.chartTitle.Font.Name = [StyleIndex].Offset(tFONT, idx - 1)                      Doesn’t work, results in error below…

     

    Saturday, January 25, 2014 8:17 AM