How to get Shape's internal name in Excel

ぃ、小莉子 提交于 2019-12-05 05:53:00
Charles Williams

Immediately after you have added the shape to a worksheet (oSht) you can use oSht.Shapes(Osht.Shapes.count) to reference it. So, oSht.Shapes(osht.shapes.count).Name will give you its name.

If you want to find the index of a shape in the Shapes collection and you know its name then you need to loop through Shapes.Name until you find it. If you know the Index, then you can construct the "Picture n" alternate name, or you can store the "Picture n" alternate name. You can also store the ID property of the shape and then reference the shape by looping through the Shapes collections until you find the Shape.ID

If the user moves the shape to a different sheet and then renames it, there is no way of identifying it as the original shape, because the external name, alternate name, Shapes index, and ID will all be different. So, if this is a problem in your scenario you would need to consider shadow copying or sheet protection.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!