View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Sharad Naik Sharad Naik is offline
external usenet poster
 
Posts: 212
Default Turn Off Macros With Workbook Open

If you want users not to inturrupt the macros, then
use it in each and every procedure (i.e. every 'Sub'), and it must be the
first line in each and every procedure.

(Be carefull before puting this in to a procedure. Ensure that your
procedure is all correct and will not go in to a
infinte loop. Then only put this code in the procedure.
Because once this is put, there is no way to interrupt the
macro., you will have to forcefully switch off the PC.)

Sharad

"Paul Moles" wrote in message
...
Thanks for this.

Where / how do I use
Application.EnableCancelKey - xlDisabled

Many Thanks

"Sharad Naik" wrote:

Sorry it should be = False in the last code line in my below post.
Sharad
"Sharad Naik" wrote in message
...
In Auto_Open Macro add following code at the top

On Error Resume Next
10
y = Application.CommandBars("Visual Basic").Controls("Design
Mode").ID
If Err = 0 Then
Application.CommandBars("Visual Basic").Controls("Design
Mode").Delete
GoTo 10
End If
Application.CommandBars.DisableCustomize = True
On Error GoTo 0

This will delete, the Design Mode button on Visual Basic tool bar.
Since
someone can add many
Design toolbars, the code ensures to delete all of them.
The last but one line of the code then disables Customize button on the
Tools Menu bar, so that the
user can not add the button back.
Please note that the users will not be able to customize tool bar at
all,
even after they close the
workbook with above code or even after restarting excel.

In the workbook before close event you may like to add code to allow
the
customization of the tool bar, which
will be as under.

Application.CommandBars.DisableCustomize = True

Sharad

"Paul Moles" wrote in message
...
Thanks for this, is there code to turn off the VB toolbar?
Thanks
Paul Moles

"Sharad Naik" wrote:


Well, If your question is, they are doing it (disabling macros) and
you
want
to know how they can do it then:-

One has to simply make VB toolbar visible, and enter in to 'design'
mode,
and close the workbook.

Sharad

"Paul Moles" wrote in message
...
I have a workbook with complementary Auto_Open and
Workbook_BeforeClose
code.

Part of Auto_Open ensures macros are enabled. With
Workbook_BeforeClose
resetting the workbook for when it is next opened.

Question having opened a workbook with macros enabled can a user
then
turn
them off sometime during the use of the book, thereby disabling my
Workbook_BeforeClose code. (Access to Macro code is password
protected)

Could not find correct placement/syntax for
Application.EnableCancelKey -
xlDisabled. but having tried Ctrl+Break, it has no effect as these
macros
are
not actually running while the book is in use.

Many Thanks
Paul Moles