How to handle ALL keystrokes

N

Norbert C. Maier

Hello!

We try to keep certain areas of word-documents (marked by bookmarks) from
direct changes.

The idea is to test on every (!) change to the document wether the cursor /
the selection is currently in such an area.
If not - nothing unusual happens.
If yes there should open a form that contains the respective text. After
having made the changes the user closes the form and the changed text is
inserted back to the document.

The test wether or not the cursor / selection stand in such an area as well
as the form are ready to use.

But we haven´t found a way to bind the test to _any_ keystroke / change to
the document.

Is there a way?
Or is there a Change-event for documents?

Greetings and thanks in advance!
Harald Dehner
 
J

Jonathan West

Norbert C. Maier said:
Hello!

We try to keep certain areas of word-documents (marked by bookmarks) from
direct changes.

The idea is to test on every (!) change to the document wether the cursor
/ the selection is currently in such an area.
If not - nothing unusual happens.
If yes there should open a form that contains the respective text. After
having made the changes the user closes the form and the changed text is
inserted back to the document.

The test wether or not the cursor / selection stand in such an area as
well as the form are ready to use.

But we haven´t found a way to bind the test to _any_ keystroke / change to
the document.

Is there a way?
Or is there a Change-event for documents?

The nearest such event is the WindowSelectionChange event which triggers
whenever you change the selected text by means of the mouse or the arrow
keys. This might be sufficient for your purpose - the code in the event can
check whether the cursor has moved into a forbidden area, and move the
cursor back out if it has.

Take a look at this article for how to create code for application events

Writing application event procedures
http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

Another possibility is to put section breaks round the non-changing parts,
and set those sections as protected for forms. Since there are no formfields
in those sections, no changes will be permitted.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

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.

Ask a Question

Top