Disable Print Option in File Menu for a workbook

tompsed

New Member
Joined
Jun 7, 2006
Messages
4
I am making an excel sheet for quality control use and only want the user to be able to print via a button that I put on the sheet. So I need to disable to the option to print from the File menu. I am running excel 2000.

Thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
in the worksheet open sub try

Code:
CommandBars("Worksheet Menu Bar").Controls("File").Controls("Print...").Delete

but make sure you put this in the close
Code:
CommandBars("Worksheet Menu Bar").Reset
 
Upvote 0
Gives Run Tim error 91

The code in the open gives Run Tim error 91.
Object variable or With block variable not set.

Any ideas?
 
Upvote 0
The code does work, running it in the open method is to soon

The code does work, running it in the open method is to soon. I ran it separately after the sheet was opened and it works well.

So I need for it to run automatically, but after the open method.

Is there a way to do this?
 
Upvote 0
Hi,

I think that rather than having to delete all Commandbar\Menu Printing Items you should set a global Boolean flag at the start of your Button code to indicate that the Printing is requested from the Button.

So , the Button code should look something like this :

Code:
'\\ in a Standard Module

Global g_blnCustomPrint As Boolean


Sub PrintTest() ' \\ Button Code

    g_blnCustomPrint = True
    
    '\\ do your printing stuff here...
    Sheet1.PrintOut
    
    g_blnCustomPrint = False

End Sub

Then you just need to place this in the ThisWorkBook Module :

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)

    If Not g_blnCustomPrint Then Cancel = True

End Sub

I assume here that Sheet1 is the worksheet being printed. Change this as required.

Regards.
 
Upvote 0
Worked well.

Either way was a little questionable. I am not a big fan of global variables, but meddling with the menu system is probably more dangerous.

Thanksssssssssssssssss
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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