PDA

View Full Version : How to jump between form and document



GOGGS75
10-30-2007, 01:55 PM
Hi,

I have been using VBA for quite some time but only started using the option of a vbmodeless userform recently.

A problem that I am having with Word when displaying a userform with the vbmodeless option on is that the user needs to click twice on the document to select a cell within a table while a userform is showing. The first click changing the focus to the document, the second click selecting the cell ?

There is no problem with this on Excel as a cell is selected using only one click.

Any help appreciated.

Goggs75

mitchell50
10-30-2007, 02:54 PM
You can set your form as "always on top" then set focus on the document using Windows API's. You could also capture the mouse through API callbacks (a little dangerous) then map the click to the document location and do a "software click" on the window client area. (The last suggestion is probably overkill.) Using the first suggestion can reverse your problem (requiring two clicks on your window to generate a click event) but maybe that is better than having to click twice on the document.

TonyJollans
10-31-2007, 03:57 AM
Word and Excel work differently in this respect - AFAIK the same behaviour happens with the built-in dialogues. Each method has its advantages and disadvantages. I think it's just something you have to live with.

fumei
10-31-2007, 11:51 AM
"There is no problem with this on Excel as a cell is selected using only one click."

That is because Excel IS a structure of cells.

Word IS not.

"(requiring two clicks on your window to generate a click event) "

The clicks are not generating a click event. They are directing focus. The first to the document. The second to select the cell.

Two separate and distinct actions.

GOGGS75
10-31-2007, 12:09 PM
Thanks for the advice, I have decided to settle for two clicks instead of venturing with Windows API.

Goggs75

fumei
10-31-2007, 12:15 PM
Not a bad choice.