Hi,
I have a form that opens on top of a doc so the user can perform a search. The form is rather minimal, but
it still gets in the way sometimes and covers the search hit (selected text in the doc).
I want the form to move out of the user's view. Since the search hit is selected, I could use the
insertion point's position on the screen as reference, but I don't know how to do that in VBA or using an
API call.
Any help would be highly appreciated.
Regards,
Guillermo
Jonathan West - 20 Jun 2007 22:45 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Any help would be highly appreciated.
There is nothing in the Word object model that will tell you the location of
the cursor on screen. It might be possible to do using the Windows API, but
I don't know how. You might get some help from the group
microsoft.public.vb.winapi. Make sure you clearly state you are using VBA in
Word - that group deals with VB6, but it is sufficiently similar to VBA that
they may be able to help, but it will assist them if they know what they are
dealing with.
However, it might prove not to be possible at all - Word's windows are
pretty weird and non-standard beasts, and trying to hook them by normal
Windows techniques often has undesirable side effects.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Tony Jollans - 24 Jun 2007 22:55 GMT
(Window_Ref).GetPoint will return the position in the window of the
Selection - in pixels. Form co-ordinates are measured in points so you will
need to convert using PixelsToPoints. These numbers can be awkward to work
with and may be unreliable but it is certainly better than nothing.

Signature
Enjoy,
Tony
> Hi,
>
[quoted text clipped - 11 lines]
>
> Guillermo