Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

How to catch a KeyPress event in word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina - 10 Nov 2005 20:44 GMT
Hi all.

I am trying to customize a word document so that a user is only allowed to
use custom buttons.
Anything else is hidden / disabled - that works alright ... apart from

1. how can I detect/ avoid a keyPress ( CTRL + S ) in order for the file
saveas dialog not to come up
when a word document is coming from template e.g. 'KD.dot' ?

2. how can I stop the user from possible disabling macros when
opening/closing my doc when template = KD.dot ?

3. do I have to think on anything else re my problem ?

any help highly appreciated - like always

thanks in advance

Gina
Jonathan West - 10 Nov 2005 21:02 GMT
Hi Gina,

Are you trying to prevent people from accidentally doing the wrong thing, or
are you trying to secure the document against unauthorised deliberate
modifications?

Signature

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

> Hi all.
>
[quoted text clipped - 16 lines]
>
> Gina
Gina - 11 Nov 2005 07:50 GMT
Hi Jonathan.

thanks for your answer .... I think the latter of your answer applies.

what I am trying to do:

in a document (new) generated by access and filled with data only two things
are allowed for the user apart from looking at it ;-))
print it, close it and quit word application itself without giving the
possibility of saving it

1. as single printout
2. as double printout
so this all works ... but keys like CTRL + S are still available

I know it sounds strange but I decided it is the right thing - all
customisation should be avoided
and I try to think of all possibilities.

Gina

.
> Hi Gina,
>
[quoted text clipped - 22 lines]
> >
> > Gina
Jonathan West - 11 Nov 2005 09:36 GMT
Hi Gina,

If you are trying to devise a security scheme for Word such that documents
can't be edited, let me tell you that nothing you can do within Word will
prevent a sufficiently determined and resourceful user from breaking the
security. For instance

1. Opening the document with Word set to High or Very High security will
prevent all VBA code from running.

2. Inserting the document into a blank document will strip off all VBA code.

I can think of several other ways of breaking the security.

I'm just trying to warn you off spending a lot of time and effort pursuing
an unattainable technical solution to this.

If a technical solution is not possible, then you have to consider other
approaches - and this essentially consists of educating your users to behave
right. Then you don't *need* all this security.

If you really want a document that can just be viewed and printed, then I
suggest you buy a copy of Adobe Acrobat and convert it to PDF format and
apply the appropriate security to the PDF file.

Signature

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

> Hi Jonathan.
>
[quoted text clipped - 48 lines]
>> >
>> > Gina
Gina - 11 Nov 2005 10:01 GMT
Jonathan...

oh ... oh ... dear ....
well .... nothing really I can do, can I....
NOPE

I am more or less happy with what I got right now - nothing more is
posssible
I got rid of the ctrl + s keypress by using Jean-Guy's code

ok ... so at this point I can stop spending more time on my strange idea
:-((

despite all ... thanks for your answer !!

have a nice weekend
Gina

> Hi Gina,
>
[quoted text clipped - 73 lines]
> >> >
> >> > Gina
Jezebel - 10 Nov 2005 22:05 GMT
> Hi all.
>
[quoted text clipped - 5 lines]
> saveas dialog not to come up
> when a word document is coming from template e.g. 'KD.dot' ?

Assign that keystroke combination to your own macro.

> 2. how can I stop the user from possible disabling macros when
> opening/closing my doc when template = KD.dot ?

You can't.

> 3. do I have to think on anything else re my problem ?

Depends on what your problem is, but I suggest you consider the implications
for the user of having Word behave in such strange and unpredictable ways.
If you're trying for security, it won't work. If you're trying to be
'helpful' your efforts are likely to be counterproductive: people *learn* to
use Word and expect it to behave in predictable, standard ways. Making
changes as you describe will annoy experienced users and confuse novices.

> any help highly appreciated - like always
>
> thanks in advance
>
> Gina
Gina - 11 Nov 2005 08:05 GMT
Hi Jezebel.

To hide everything apart from my custom commandbar (with 2 buttons) is/was
in fact first to not confuse the novices ( I know, these people are bloody
novices!!! - they were still using a typing machine)
Second ... in order to avoid not renewing the license for my program but
make use of the template that comes with my access.mdb ( and all the work
that went with it) the document should not be allowed to save ...

it can always be generated by the access program

so I catered for that so far (thanks to the help of the group!!) and all
works fine more or less
all but the keypress thing and things I haven't thought of yet or do not
know

Gina

> > Hi all.
> >
[quoted text clipped - 27 lines]
> >
> > Gina
Jean-Guy Marcil - 10 Nov 2005 22:09 GMT
Gina was telling us:
Gina nous racontait que :

> Hi all.
>
[quoted text clipped - 5 lines]
> file saveas dialog not to come up
> when a word document is coming from template e.g. 'KD.dot' ?

In your template, insert two subs as follows:

Sub FileSave()

End Sub

Sub FileSaveAs()

End Sub

These will make the save and save as actions "inert".

> 2. how can I stop the user from possible disabling macros when
> opening/closing my doc when template = KD.dot ?

In short, you can't.

> 3. do I have to think on anything else re my problem ?

Maybe, it is difficult to comment as we do not really know why you want to
do these things...

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 
Gina - 11 Nov 2005 08:09 GMT
Hi Jean-Guy,

many thanks for code!!
will I have to leave these two subs blank ???

For what I am trying to do please see above answers to posts

Thanks,
Gina

> Gina was telling us:
> Gina nous racontait que :
[quoted text clipped - 36 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil - 11 Nov 2005 13:27 GMT
Gina was telling us:
Gina nous racontait que :

> Hi Jean-Guy,
>
> many thanks for code!!
> will I have to leave these two subs blank ???
>
> For what I am trying to do please see above answers to posts

If you leave them blank, nothing will happen, or, you could warn the user
with:

MsgBox "You are not allowed to save a copy of this document."

Whatever code you put in the subs will be executed whenever the user tries
to save (or save as).

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Klaus Linke - 11 Nov 2005 19:02 GMT
... but even without knowledge (or acess) to VBA, users could still choose
"Tools > Macro > Macros in: Word Commands > SaveAs" (if they kow about it)
to run the built-in command.

Klaus

> Gina was telling us:
> Gina nous racontait que :
[quoted text clipped - 13 lines]
> Whatever code you put in the subs will be executed whenever the user tries
> to save (or save as).
Jean-Guy Marcil - 11 Nov 2005 20:21 GMT
Klaus Linke was telling us:
Klaus Linke nous racontait que :

> ... but even without knowledge (or acess) to VBA, users could still
> choose "Tools > Macro > Macros in: Word Commands > SaveAs" (if they
> kow about it) to run the built-in command.

...or disable macros all together...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Gina - 12 Nov 2005 08:23 GMT
Klaus ....

thanks for reality ;-)
well.... in the doc generated by access and opened with a macro in word that
disables all but a custom bar that contains two buttons (to print it), they
of course have the option of editing it in some way as well as copy and
paste ( via keyboard) presumably text from the clipboard ....

I tested to set the security settings to high as suggested earlier in this
thread .... and was really disarming :-((
absolutely no macro runs ....

so if the settings are not at the highest level, or the one below I cannot
see how they could choose
> "Tools > Macro > Macros in: Word Commands > SaveAs" (if they kow about it)

because there is no menu either .... being very doubtfull about my basic
word knowledge !!
I wonder how then what you suggested could happen .... ??

Gina

> ... but even without knowledge (or acess) to VBA, users could still choose
> "Tools > Macro > Macros in: Word Commands > SaveAs" (if they kow about it)
[quoted text clipped - 19 lines]
> > Whatever code you put in the subs will be executed whenever the user tries
> > to save (or save as).
Klaus Linke - 12 Nov 2005 11:45 GMT
Hi Gina,

> because there is no menu either [...]

Yeah, missed the point that you customized that away. The user would have to
add it again?
Say with "right-click > Customize" on your toolbar...

My point, same as all others that responded, is that you likely can't close
all the loopholes.

Regards,
Klaus

> Klaus ....
>
[quoted text clipped - 48 lines]
> tries
>> > to save (or save as).
Gina - 12 Nov 2005 12:35 GMT
No Klaus ... there is no right-click either anymore .....
I very much appreciate all your answers and ideas I have not thought of
.... ( believe me, it took some time as well as big help from the group!!
before I got word where it is now and normal.dot and any other word stuff
still behaving 'normal' .... when the security settings are not high ....
only my templates are affected of all that disabling customisation stuff!!

as they are novices anyway .... they won't know about at least not in the
nearer future :-) .... I hope :-))
all the data transfer to word, proper formatting etc ... etc... took quite
an amount of programming in access together with preparing the templates
with company logos etc. to give it 'em the same look as the ones from the
typing machine ( they just look - of course - more neet and accurate) ...

I just wanted to make sure that I have done my best .... with the given
elements....
I will see ;-))

Thanks to everyone who answered this and my other threads in the word group
adding to my 90% success in this case - that got more and more suprises for
me to solve as I went along !!

Just one thing comes to my mind .... if the user wouldn't know that it is
Word what is showing up the document, a normal user would not know to change
security settings to high in order to not run any of the underlying vba so
that a 'save' could be performed
oh dear .... this gets a mad touch now ....
is it possible to remove the first 'bar' where it becomes clear which
program is opened ??? showing Dokument 1 - Microsoft Word .... well I would
have to get rid of the icon in the top left corner as well ....

I guess or I am sure microsoft wouldn't allow for that!!

Gina

> Hi Gina,
>
[quoted text clipped - 62 lines]
> > tries
> >> > to save (or save as).

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.