如何从Visio中获取形状的X和Y坐标?

huangapple go评论186阅读模式
英文:

How to get a shapes X and Y coordinate from Visio?

问题

大家好,我在一个Visio VBA项目中遇到了问题。我在一个工作表上有一个形状,并且我有它的“ID”。但出于某种原因,我无法从该形状获得准确的X-Y坐标。

我尝试了以下代码:

        Set shpObj = Application.ActiveWindow.Page.Shapes.ItemFromID(blockID)
        Set celObj = shpObj.Cells("pinX")
        localCent = celObj.Result("inches")
        LocationX = Format(localCent, "000.0000")
        
        Set shpObj = Application.ActiveWindow.Page.Shapes.ItemFromID(blockID)
        Set celObj = shpObj.Cells("pinY")
        localCent = celObj.Result("inches")
        LocationY = Format(localCent, "000.0000")

明确一下,我能够从中获得数字,但这些数字从不改变。我认为我得到的是某种本地形状坐标,而不是工作表坐标。谢谢。

英文:

Good day to you all, I am having trouble with a Visio VBA project. I have a shape on a sheet and I have its "ID". But for some reason I cannot get accurate X-Y coordinates from the shape.

I tried the following code:

        Set shpObj = Application.ActiveWindow.Page.Shapes.ItemFromID(blockID)
        Set celObj = shpObj.Cells("pinX")
        localCent = celObj.Result("inches")
        LocationX = Format(localCent, "000.0000")
        
        Set shpObj = Application.ActiveWindow.Page.Shapes.ItemFromID(blockID)
        Set celObj = shpObj.Cells("pinY")
        localCent = celObj.Result("inches")
        LocationY = Format(localCent, "000.0000")`

To be clear I am getting numbers form this, but the number never change. I think I am getting some kind of local shape coordinate not the sheet coordinate. Thanks

答案1

得分: 1

请尝试使用XYtoPage方法

希望我的文章能够帮助,可以通过Google翻译阅读

英文:

Please try use XYtoPage method.

如何从Visio中获取形状的X和Y坐标?
Hope my article can helps, please read via Google translate.

huangapple
  • 本文由 发表于 2023年6月25日 20:43:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定