Delete and Backspace event

A

Amy S.

I want to prevent users from deleting parts of the document.
Protecting template with the form does not work because I need to be able to
write to those parts programmatically.

How can I detect if Delete or Backspace keys were pressed?

I was able to do that with the arrow buttons, but not able to do that wih
delete and backspace
 
J

Jean-Guy Marcil

Amy S. was telling us:
Amy S. nous racontait que :
I want to prevent users from deleting parts of the document.
Protecting template with the form does not work because I need to be
able to write to those parts programmatically.


If you are accessing the document programmatically, you can remove the
protection prior to making changes, and then reset the protection when you
are done.

ActiveDocument.Unprotect "myPassword"
'Do your stuff here
ActiveDocument.Protect wdAllowOnlyFormFields, True, "myPassword"

This is infinitely easier than dealing with key press event from Word VBA...


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Amy S.

Thanks for your help, but now I have another question
In that case, in order to implement locking and unlocking the document, I
have parts of the document that user should be able to have access at all
times.
How do I know if the user clicked? Is there mouse click event or something
that would accomplish that goal?
I know how to determine the location of the click, but I need to trigger
that when the user clicks in the document to unlock the doc.
 
A

Amy S.

Thanks for your reply.
Your response prompted me to ask you another question:
Is there a mouse click event or something similar that would determine if
user clicked anywhere in the doc?
I know how to determine where the user clicked, but don't know how to
determine WHEN the user clicks on the doc.
That way I can determine whether to lock or unlock the document.
 
J

Jean-Guy Marcil

Amy S. was telling us:
Amy S. nous racontait que :
Thanks for your reply.
Your response prompted me to ask you another question:
Is there a mouse click event or something similar that would
determine if user clicked anywhere in the doc?
I know how to determine where the user clicked, but don't know how to
determine WHEN the user clicks on the doc.
That way I can determine whether to lock or unlock the document.

If you protect only certain sections, you can lock/unlock, and only the
sections flagged to be locked will lock/unlock...

I think that before we go any further, it would be useful at this stage that
you explained what is it you are trying to achieve.

For instance, does your code need to be called every time a user clicks
somewhere in the document?
If not, when should your code be called? What does your code do?


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Amy S.

Jean-Guy, I followed your advice and defined sections of the doc.
Then, I added the code to protect and unprotect the document and was able to
write to protected sections.

However, I ran into yet another obstacle.
There are macros in my code that have to do with the navigation of the
unprotected table.
When user clicks an arrow down button, the cursor jumps not to a cell
directly below, but to the one on the very left. (That's what users wanted)

When the document is protected, I am able to freely write in the unprotected
section, but my navigation macros stop working. They only work when the doc
is unprotected. So, I still need to know how to catch the mouse click event.

Thanks so much for your help
 
J

Jean-Guy Marcil

Amy S. was telling us:
Amy S. nous racontait que :
Jean-Guy, I followed your advice and defined sections of the doc.
Then, I added the code to protect and unprotect the document and was
able to write to protected sections.

However, I ran into yet another obstacle.
There are macros in my code that have to do with the navigation of the
unprotected table.
When user clicks an arrow down button, the cursor jumps not to a cell
directly below, but to the one on the very left. (That's what users
wanted)

When the document is protected, I am able to freely write in the
unprotected section, but my navigation macros stop working. They only
work when the doc is unprotected. So, I still need to know how to
catch the mouse click event.

What code are you using to capture/replace the down arrow key when in
tables?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.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