Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this piece of VBA code

With sheet1.ChartObjects("Chart 2").Chart.Axes(xlValue)
        .MinimumScale = ChartMinY
        .MaximumScaleIsAuto = True
End With

When execution comes to .MinimumScale = ChartMinY where ChartMinY is 0.0844, excel throws an exception.

Err.Description is

Automation error
Unspecified error 

and Err.Number is -2147467259

It apparently works in Excel 2002

share|improve this question
Do you mean ChartMinY is 0.0844? – Karan Sep 13 '12 at 3:01
@Karan You're right! I have fixed the typo in the question – Anthony Kong Sep 13 '12 at 3:05
Try hovering the mouse over that line and the preceding one, to check if any variable has an invalid value that might be the cause of this issue. – Karan Sep 13 '12 at 3:08
Is your worksheet protected? – SeanC Sep 13 '12 at 19:33
@SeanCheshire It is. If I unprotect before the call, it works. Please reproduce your comment as an answer so I can accept it. BTW, I have an automation error when I tried to set TickLabels.NumberFormat to "0.000" even after the sheet is unprotected. Is it also a known issue? – Anthony Kong Sep 13 '12 at 23:56
up vote 1 down vote accepted

Is your worksheet protected?

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .