VBA:尝试在项方法中传递字符串的类型不匹配错误

问题描述

我正在尝试编写一个VBA代码,该代码从excel范围获取位于我的Powerpoint幻灯片上的图表名称和意甲名称,以便为我提供相应datalabel的位置。由于某种原因,我遇到了类型不匹配错误。我认为当我将字符串变量作为'item'方法的参数传递时会发生这种情况,因为当我用它们的实际字符串值替换它们时,代码可以正常工作。

Sub datalabelposition()
 
Dim pp As Object
Dim sl As Object
Dim chtName As Variant
Dim serName As Variant
Dim rnge As Range
 
Set pp = CreateObject(class:="PowerPoint.Application")
Set sl = pp.ActivePresentation.Slides(1)
Set rnge = Worksheets("Macro").Range("J10:P29")
 
chtName = rnge(1,1).Value
chtName = CStr(chtName)
serName = rnge(1,2).Value
serName = CStr(serName)
 
Debug.Print chtName
Debug.Print serName
Debug.Print sl.Shapes.Item(chtName).Chart.SeriesCollection.Item(serName).Points(1).DataLabel.top
 
End Sub

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)