|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
以下是引用gao2ming1在2007-5-19 21:05:30的发言:请高手帮忙: 1.如何用vba选中最后插入的代码(不知道名称) 2.如何获取选中文字的宽度? 谢谢 '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-5-20 6:51:42 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0208^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit
Sub Sample1() '选定文档最后插入的一个图形 ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Select 'ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count).Select End Sub '---------------------- Sub Sample2() Dim pLeft As Long Dim pTop As Long Dim pWidth As Long Dim pHeight As Long '以像素为单位返回所选内容的宽度等值 ActiveDocument.ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range '以厘米为单位返回所选内容的宽度 MsgBox "您所选内容的宽度为" & Word.PointsToCentimeters(Word.PixelsToPoints(pWidth)) & "厘米" End Sub '----------------------
|
|