Disabling Toolbar buttons and CommandBar items

J

Jim

Hello,

I'm trying to disable the print CommandBar items and
toolbar buttons from a specific Excel workbook on the
WhenClick event of a custom button. The problem is that
in so ding, I end up disabling the functionality for any
workbook I open after executing my code. Any ideas on how
I can limit the sciope to the individual workbook I'm
working on? I'm sing Excel XP. Here's a snippet of my
code:

Toolbars("Standard").ToolbarButtons(7).Enabled = False

With CommandBars("File")
.Controls("Print...").Enabled = False
.Controls("Print Preview").Enabled = False
End With
 
W

William

Hi Jim

Rather than disabling the toolbar buttons (which can be easily overcome if a
User has other "custom" buttons on a toolbar, a better option may be to use
the following (which should be placed in the "ThisWorkbook" module) and
which will only effect the workbook you enter this code in.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub


--
XL2002
Regards

William
(e-mail address removed)

| Hello,
|
| I'm trying to disable the print CommandBar items and
| toolbar buttons from a specific Excel workbook on the
| WhenClick event of a custom button. The problem is that
| in so ding, I end up disabling the functionality for any
| workbook I open after executing my code. Any ideas on how
| I can limit the sciope to the individual workbook I'm
| working on? I'm sing Excel XP. Here's a snippet of my
| code:
|
| Toolbars("Standard").ToolbarButtons(7).Enabled = False
|
| With CommandBars("File")
| .Controls("Print...").Enabled = False
| .Controls("Print Preview").Enabled = False
| End With
 

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