Re: GetCaretPos can't get the correct value by wak
wak
Tue Jul 15 08:10:02 PDT 2008
"Helmut Weber" wrote:
> Hi,
>
> at work, with Office 2002 and Windows XP
> I see the same behaviour as you do.
>
> However, at home, with Vista Small Business
> and Office XP, the following code is working:
>
> Option Explicit
> ' ---------------------------------------------
> Public Declare Function GetCaretPos Lib "user32" _
> (lpPoint As POINTAPI) As Long
>
> Private Type POINTAPI ' 8 Bytes
> x As Long
> y As Long
> End Type
>
> Public Sub WhereAmI()
> Dim p As POINTAPI
> Dim l As Long
> l = GetCaretPos(p)
> ActiveDocument.Range.InsertAfter _
> "(" & p.x & "," & p.y & ")"
> MyStart
> End Sub
>
> Sub MyStart() ' for ongoing evaluation of caret position
> Application.OnTime _
> When:=Now + TimeValue("00:00:03"), _
> name:="WhereamI"
> End Sub
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>
Thanks for your code, it realy work.
but I want to know a common way to get
the caret pos of all versions of word,
and outlook have the same problem,
(GetCaretPos works ok in powerpoint).
Microsoft knows the caret pos, so i believe
there is a way to get it correct, any idea?