英文:
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翻译阅读。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论