GetActiveWindow through automation

S

sw19mike

I have a Word 2002 template which has a routine to prevent the user from
saving the file, by removing Close, Save, Save as, and Exit menu items,
disabling the Save tool from the toolbar, and disabling the top-right 'X'
button in Word. It does this using the following code:

DeleteMenu GetSystemMenu(GetActiveWindow,False),6,1024

This works fine if I just double click the .dot to create a new file, but
when I open through automation, GetActiveWindow always returns 0 (zero), so
the X button is not disabled. Any ideas anyone?
 
J

Jezebel

Forget about it. What you're trying to do cannot be done. Experienced users
will have no trouble bypassing your 'security', and novices will complain
that you've wrecked their copy of Word.

Amongst other ways of bypassing your security --

1. Open the document with macros disabled.

2. Run the commands from Macros > Run (select 'Word Commands' from the
'Macros In' list)

3. Switch to VBA and execute the commands in the Immediate window.

4. Right-click any toolbar, select Customize, reset the File menu.
 
S

sw19mike

Thanks for the fast response, but your making assumptions is not appropriate.
This is not a matter of 'security' but of a usable interface. If the user
wishes to bypass it, I don't have a problem. I am simply trying to reduce
the options available to him to make his life easier.

As for 'it cannot be done', I simply don't believe it.

Anyone else?
 
J

Jezebel

Prowl the archive. This topic comes up about three times a week and the
answer is always the same. Sorry if that's not the answer you want, but
intransigence doesn't make it possible.
 

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