Shape的Left或Top值与不同的方式和版本不相符 [英] Shape's Left or Top value does not tally for different ways and versions

查看:325
本文介绍了Shape的Left或Top值与不同的方式和版本不相符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


对于以下单词中的vba代码:

 Sub iterate_selection()
For Each shp In Selection.ChildShapeRange
MsgBox" name:" &安培; shp.Name& vbLf& _
" &安培; shp.Left& vbLf& _
" &安培; shp.Top
下一个
结束子

Sub iterate_shapes()
For Each canva在ActiveDocument.Shapes
如果canva.Type = 20和canva。 Name = Selection.ShapeRange.Item(1).Name Then
For each shp in canva.CanvasItems
如果shp.Name = Selection.ChildShapeRange.Item(1).Name那么
MsgBox" ;姓名:" &安培; shp.Name& vbLf& _
" &安培; shp.Left& vbLf& _
" &安培; shp.Top
结束如果
下一个
结束如果
下一个
结束子

按以下步骤测试2010年和2013年办公室:


1。创建一个画布

2.在画布中心插入任何形状

3.选择刚插入的形状

4.运行两个子一个接一个


以下是我的结果:


< img alt =""src ="https://social.msdn.microsoft.com/Forums/getfile/1135368">


如果离开或顶部shape的值是按点计算的,我认为正确的值应该是Office 2010 + CavnvasItems,其他值除以20.那么在单词vba中获取形状的左值和顶值的一致方法是什么?

解决方案

你好ocaoms,


我可以重现你的问题。我建议你去File-> Feedback提交这个问题的反馈。根据目前的结果,我建议你使用第一部分代码来获得左边和最高值。


最好的问候,


特里


Hi,

For below vba code in word:

Sub iterate_selection()
    For Each shp In Selection.ChildShapeRange
        MsgBox "name: " & shp.Name & vbLf & _
            " & shp.Left & vbLf & _
            " & shp.Top
    Next
End Sub

Sub iterate_shapes()
    For Each canva In ActiveDocument.Shapes
        If canva.Type = 20 And canva.Name = Selection.ShapeRange.Item(1).Name Then
            For Each shp In canva.CanvasItems
                If shp.Name = Selection.ChildShapeRange.Item(1).Name Then
                    MsgBox "name: " & shp.Name & vbLf & _
                        " & shp.Left & vbLf & _
                        " & shp.Top
                End If
            Next
        End If
    Next
End Sub

Test by below steps with office 2010 and 2013:

1. create one canvas
2. insert any shape in center of the canvas
3. select the shape just inserted
4. run the two sub one by another

Below is my result:


If left or top value of shape is by points, I think the correct value should be Office 2010 + CavnvasItems, the other values are divided by 20. So what is the consistent way to get left and top values of a shape in word vba?

解决方案

Hi ocaoms,

I could reproduce your issue. I would suggest you go to File->Feedback to submit a feedback for this issue. According to current result, I would suggest you use first part code to get the left and top values.

Best Regards,

Terry


这篇关于Shape的Left或Top值与不同的方式和版本不相符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆