I have a spreadsheet that worked great in Excel 2003, but now testing Excel 2007, I am 'blowing up' on the MajorUnit property of an Axes.
Is there anyone out there who can tell me why the following code worked in 2003, and now blows up in 2007 with an error message that says:
"Error -2147467259: Method MajorUnit of Object Axis failed"
Here is the code...
Set wb = ThisWorkbook
Set w = wb.Worksheets("Graphs")
Set c = w.ChartObjects(1).Chart
Set srs = c.SeriesCollection(1)
s = srs.FormulaR1C1
i = InStr(6, s, ":R")
j = InStr(i, s, "C")
sC = Mid(s, i, j - i)
j = w.ChartObjects.Count
For i = 1 To j
Set c = w.ChartObjects(i).Chart
Set a = c.Axes(xlValue)
' THIS IS WHERE THE THING FAILS
With a
.MajorUnit = MaxStaff / 5
.MaximumScale = MaxStaff
.MinimumScale = 0
End With
For Each srs In c.SeriesCollection
s = Replace(srs.FormulaR1C1, sC, sN)
srs.FormulaR1C1 = s
Next
Any help figuring this one out is GREATLY appreciated!
- Beebo
Is there anyone out there who can tell me why the following code worked in 2003, and now blows up in 2007 with an error message that says:
"Error -2147467259: Method MajorUnit of Object Axis failed"
Here is the code...
Set wb = ThisWorkbook
Set w = wb.Worksheets("Graphs")
Set c = w.ChartObjects(1).Chart
Set srs = c.SeriesCollection(1)
s = srs.FormulaR1C1
i = InStr(6, s, ":R")
j = InStr(i, s, "C")
sC = Mid(s, i, j - i)
j = w.ChartObjects.Count
For i = 1 To j
Set c = w.ChartObjects(i).Chart
Set a = c.Axes(xlValue)
' THIS IS WHERE THE THING FAILS
With a
.MajorUnit = MaxStaff / 5
.MaximumScale = MaxStaff
.MinimumScale = 0
End With
For Each srs In c.SeriesCollection
s = Replace(srs.FormulaR1C1, sC, sN)
srs.FormulaR1C1 = s
Next
Any help figuring this one out is GREATLY appreciated!
- Beebo