本示例将所选内容移到当前行首,将移动的字符数赋给变量 pos。并显示出来。

pos = Selection.HomeKey(Unit:=wpsLine, Extend:=wpsMove)
If pos = 0 Then
    MsgBox "Selection was not moved"
Else
    MsgBox "Selection was moved :" & pos
End If