Disable Print from File Menu and Toolbar

Stelios Panayides

New Member
Joined
Jul 28, 2008
Messages
14
I am using the following two macors to disable Print from File Menu and Toolbar:

Sub DisableMenuItems() <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
With CommandBars("File") <o:p></o:p>
.Controls(12).Enabled = False <o:p></o:p>
End With <o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Sub DisableCommandBarControl() <o:p></o:p>
Dim cb As CommandBar<o:p></o:p>
Dim bc As CommandBarControl <o:p></o:p>
For Each cb In CommandBars<o:p></o:p>
For Each bc In cb.Controls<o:p></o:p>
If Left(bc.Caption, 5) = "Print" Then _<o:p></o:p>
bc.Enabled = False<o:p></o:p>
Next<o:p></o:p>
Next <o:p></o:p>
End Sub

The macros work fine but the problem is that the macors apply to all Excel files on my pc and that they do not work when I open the file for manother pc (after adjusted the security setting and enabling the macros)!!!

ANY HELP WOULD BE HIGHLY APPRECIATED.

THANK YOU
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveWorkbook.Name = ThisWorkbook.Name Then
MsgBox "Printing disabled"
Cancel = True
End If
End Sub

in 'ThisWorkbook".
However, if the workbook is opened with macros disabled then this will not work. To overcome this you need to have all worksheets (except for a 'dummy' worksheet) set as 'very hidden' and then unhide them in the Workbook_Open event.
 
Upvote 0
Thanks for the response but with this macro I cannot print at all using the macro.

The problem is that the two macros that disable printing from File menu and Toolbar (which allow to print when using a special macro for printing)
apply to all Excel files on my pc and that they do not work when I open the file from another pc (after adjusted the security setting and enabling the macros)!!!
 
Upvote 0
The intention was that the code that I gave should replace your two macros. You could then modify the code as required.

You did not say where the macros are stored. Are they in your personal workbook? Or in your default workbook template? Do they work if one of your workbooks is also open when you open the received workbook? If they do not exist in the workbook that you are receiving from another PC, they need to be 'publically' available for use in any workbook that you open.
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,108
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top