我想问,为什么有时当我在一个选定的文本框上使用下面的代码时,我会得到多个小数位的msgbox返回值(例如:3-6位小数),有时它会返回一个带有相同文本框的整数
Sub getShapeNow()
With ActiveWindow.Selection.ShapeRange(1)
MsgBox .Name
MsgBox .Width
MsgBox .Height
MsgBox .Top
MsgBox .Left
End With
End Sub发布于 2018-04-30 16:52:18
Powerpoint显然不支持任何宽度,但只支持一些宽度,这是基于屏幕分辨率。因此,如果您尝试
Sub GetShapeNow()
With ActiveWindow.Selection.ShapeRange(1)
.Width = 47.00147
Debug.Print .Width
End With
End Sub我会在“即时”窗口中看到47.0015打印出来,因为我的rezolution不支持与.00147一样精确的Width。
属性是逗号后面带有值的小数。如果逗号后没有值,例如47而不是47.01,则VBA将该值写为47。
请检查以下内容:
Sub GetShapeNow()
With ActiveWindow.Selection.ShapeRange(1)
.Width = 47
.Height = 34
.Top = 40.4
.Left = 147
Debug.Print .Name; .Width; .Height; .Top; .Left
End With
End Sub在“即时”窗口中,您可以看到:
Rectangle 1 47 34 40,4 147 通常,Shape.Width返回的值来自Single类型
https://stackoverflow.com/questions/50094478
复制相似问题