这个VBA代码尝试绘制" Casa"黑色线:
Dim ActiveSheet As Worksheet
Dim oChart As Chart
Dim oSeries As Series
Set ActiveSheet = Sheets("Gráficas")
ActiveSheet.ChartObjects("Gráfico 200").Activate
Set oChart = ActiveChart
For numLine = 1 To oChart.SeriesCollection.Count
Set oSeries = oChart.SeriesCollection(numLine)
MsgBox oSeries.name
If oSeries.name = "Casa" Then
MsgBox "Success"
oSeries.Format.Line.ForeColor.RGB = RGB(0, 0, 0)
End If
Next
但是,我看到图表中所有行的名称,包括" Casa"但是没有绘制成功消息,也没有绘制黑色线条。 似乎字符串不匹配......但为什么?