1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Sub ExampleCallByName()
Dim oTextFrame2 As TextFrame2
Dim oObj As Object
Set oTextFrame2 = Feuil1.ChartObjects(1).Chart.SeriesCollection(1).DataLabels.Format.TextFrame2
On Error Resume Next 'cette ligne fonctionne en excel 2013
Set oObj = CallByName(oTextFrame2.TextRange, "InsertChartField", VbMethod, 7, ActiveCell ,1)
On Error GoTo 0
If oObj Is Nothing Then 'si oObj est Nothing donc on affaire a excel 2010
Debug.Print "excel 2010"
'Continue ici avec ton code alternatif pour excel 2010 ...
End If
End Sub |
Partager