返回列表 上一主題 發帖

[分享] excel 2007 shaperange 無法用 shape type for each

[分享] excel 2007 shaperange 無法用 shape type for each

Dim h_shape As Shape
Dim h_shaperange As ShapeRange

Set h_shaperange = Selection.ShapeRange

For Each h_shape in h_shaperange
       ........
Next

上面的程式在excel 2003沒有問題,但是在excel 2007,
h_shape 會是 nothing ,無法收到 shaperange 裡的 shape
目前知道的方法是把 h_shape 宣告成 Object 就可以,如下
Dim h_shape As Object

另外問個問題,如何作型態轉變
把 Object 在變回 Shape?

回復 2# kimbal

會這麼問是因為把 Option Explicit,
如果把宣告成 Object 的 shape 當其他 sub routine 的引數(shape) 會有錯誤,
不想因為這個bug把其他已經寫好的 Sub routine 的 As Shape 都改成 As Object,
不知這個 bug 有沒有 patch release?
謝謝。

BR,
Jarod

TOP

        靜思自在 : 【生命在呼吸間】佛陀說:「生命在呼吸間。」人無法管住自己的生命,更無法擋住死期,讓自己永住人間。既然生命去來這麼無常,我們更應該好好地愛惜它、利用它、充實它,讓這無常、寶貴的生命,散發它真善美的光輝,映照出生命真正的價值。
返回列表 上一主題