当试图定位图表标签时,为什么会出现溢出/ #INF错误?

我有以下程序,我用它来添加标签到图表:

Sub add_comments(apply_to As Series, source_range As Range) Dim i As Long Dim c As Range If source_range.Count > apply_to.Points.Count Then Set source_range = source_range.Resize(apply_to.Points.Count, 1) End If i = 1 For Each c In source_range If Not IsError(c) And i <= apply_to.Points.Count Then If Len(c.Text) <> 0 Then apply_to.Points(i).HasDataLabel = True apply_to.Points(i).DataLabel.Text = c.Value2 apply_to.Points(i).DataLabel.Format.AutoShapeType = msoShapeRectangle With apply_to.Points(i).DataLabel.Format.Line .Visible = msoTrue .ForeColor.RGB = RGB(0, 0, 0) End With apply_to.Points(i).DataLabel.Position = xlLabelPositionAbove Debug.Print apply_to.Points(i).DataLabel.Top apply_to.Points(i).DataLabel.Top = apply_to.Points(i).DataLabel.Top - (10 + apply_to.Points(i).DataLabel.Height) Else If apply_to.Points(i).HasDataLabel Then apply_to.Points(i).DataLabel.Delete End If End If End If i = i + 1 Next c apply_to.HasLeaderLines = True End Sub 

然而,当我运行的子,它终止上线apply_to.Points(i).DataLabel.Top = apply_to.Points(i).DataLabel.Top - (10 + apply_to.Points(i).DataLabel.Height)溢出错误。 尝试打印apply_to.Points(i).DataLabel.Top的值使得看起来像获取数据标签的最高值时出现问题: 在这里输入图像说明

然而,看图,标签似乎有一个有效的位置,应该有一个.Top值。

在这里输入图像说明

有人可以给我一个指示,说明我的程序中出了什么问题吗?