Question

I 'm trying to change font in entire chart. Recorded macro using Shapes collection > Shape object > TextFrame2 (contains text formatting for the specified shape) > TextRange > Font.

With ActiveSheet.Shapes("Chart 1502").TextFrame2.TextRange.Font
  .NameComplexScript = "Arial"
  .NameFarEast = "Arial"
  .Name = "Arial"
End With

I checked it in documentation and it seems like good way, but when I try run this recorded macto, it throws : Run-time error: '-2147024809 (80070057)': Entered value is out of range (my translation - I have localized version).

Error is on this line (especially with TextFrame2)

With ActiveSheet.Shapes("Chart 1502").TextFrame2.TextRange.Font

Because

set x = ActiveSheet.Shapes("Chart 1502")' is OK

But

set x = ActiveSheet.Shapes("Chart 1502").TextFrame2 'throws Run-Time Error
Was it helpful?

Solution

Try this one:

Sub test()
    Dim x As Shape
    Set x = ActiveSheet.Shapes("Chart 1502")

    With x.Chart.ChartArea.Format.TextFrame2.TextRange.Font
        .NameComplexScript = "Arial"
        .NameFarEast = "Arial"
        .Name = "Arial"
    End With
End Sub

I also suggest to change ActiveSheet.Shapes("Chart 1502") to something like this: Worksheets("Sheet1").Shapes("Chart 1502").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top