如何获得所选文本的宽度? [英] How to get a width of a selected text?
本文介绍了如何获得所选文本的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我需要获得文本范围的宽度(不是符号,而是图形单位 - 英寸/ tweeps /点/厘米 - 任何东西)。
有可能以某种方式吗?
$
谢谢,
George
Hello
I need to get a width of a text range (not in symbols, but in a graphical units - inches/tweeps/points/centimeters - anything).
Is it possible to do somehow?
Thanks,
George
推荐答案
嗨GeoZZ,
Hi GeoZZ,
尝试使用Word:
Sub Demo()
Dim rng As Word.Range
Dim lngLeft As Long
Dim lngRight As Long
Set rng = Selection.Range
rng.SetRange rng.Start, rng.Start
lngLeft= rng.Information(wdHorizontalPositionRelativeToPage)
Set rng = Selection.Range
rng.SetRange rng.End, rng.End
lngRight = rng.Information(wdHorizontalPositionRelativeToPage)
MsgBox PointsToCentimeters(lngRechts - lngLinks)
End Sub
这篇关于如何获得所选文本的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文