Excel VBA“选择.左”

问题描述

我使用的是带有宏的旧电子表格,它在 Excel 2010 中运行良好,但在 Excel 2016 中引发错误(运行时错误 91)。我还应该提到我没有使用 VBA 的经验。

我已将错误范围缩小到:

With Worksheets("Worksheet_name")
   .Cells(17,1) = Selection.Left
   .Cells(18,1) = Selection.Top
End With

特别是 Selection.Left 和(我希望)Selection.Top 导致了问题。我搜索了运行时错误Selection.Left,但找不到解决此问题的方法。是否有在 Excel 2016 中执行 Selection.Left 的更新方法

我没有使用 VBA 的经验,因此生成问题的 MWE 超出了我的范围(原始脚本有几千行且未注释),但希望这足以理解问题:

ActiveSheet.Shapes.AddShape(1,360,210,30,30).Select
Selection.ShapeRange.Fill.Transparency = 1
Selection.Name = "Drag me"

Dim PointBox As Shape
Set PointBox = ActiveSheet.Shapes.Range(Array("A","B","C","Drag me")).Group
PointBox.Name = "pointx"

With Worksheets("Worksheet_name")
   .Cells(17,1) = Selection.Top
End With

解决方法

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

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

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