X
xerj
Thanks in advance if anyone knows how to do it.
Thanks in advance if anyone knows how to do it.
I do event trapping on keystrokes all the time.
I suppose you're programmers, so I'll only describe the principle at
work, with minimal code.
You associate a common key with a macro. For example, the spacebar.
The necessary code would be as follows:
KeyBindings.Add 1, "MyKeyEventSpace", BuildKeyCode(wdKeySpacebar)
Every time the users presses the space bar, your MyKeyEventSpace macro
fires. Make sure the first thing the macro does is *actually* type the
space:
Selection = " ": Selection.Collapse 0
Inside that macro, you have a persistent variable (by persistent, I
mean a document variable, not a VBA variable that dies at the first
End) that records the current page number. If that number is different
from the current page, you know you moved to a different page and you
can take action.
Now you may also link some navigation keys (KeyDown, PageDown) in the
same way to make sure the macro fires even when you just navigate
without typing.
goes over the end of the page and apply formatting as the user types.xerj said:What I am after is a way to have Word automatically assess a paragraph that
goes over the end of the page and apply formatting as the user types.xerj writes:
What I am after is a way to have Word automatically assess a
paragraph that
It's a
little like widow/orphan control but there are some other added
wrinkles.
No need to bind all possible keys. IMHO, you don't need to run the
test [have we moved one page?] at *every* keystroke. Trapping the
spacebar is amply sufficient, unless xerj wants the Japanese/Chinese
to use his system - they make less use of spaces indeed.
AFAIU, xerj needs to notice when, in the course of typing, textflow
moves into a new page (do I get him right?). I would trap the Enter
key in addition to the Spacebar, but it's a matter of choice. The
less keys you trap the better. It's pretty unlikely someone would
type and type without spaces.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.