ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   re-enabling macro under menu item (https://www.excelbanter.com/excel-programming/295426-re-enabling-macro-under-menu-item.html)

jerry h

re-enabling macro under menu item
 
A few posts here provide me added knowledge. In one, it mentioned a way to disable "Print option under File", using

CommandBars("Worksheet Menu Bar").Controls("File").Controls("Print...").Enable d = Fals

Suppose I open a new Excel file. Fire up macro editor and make up one macro with the following variant
sub disableM(
CommandBars("Worksheet Menu Bar").Controls("File").Controls("Print...").Enable d = Fals
end su

I save the Excel file as test.xls. Run the macro. It "works". The macro option has gone. But then how can I get my macro option back? I thought my 'macro option' will be back if I close Excel and reopen Excel. But no, the option doesn't come back. What is the simplest solution (to give the macro function back to the user) IF this was the case

I am a little bit smarter than the dummies. I do not actually have such a problem because I "forsee" it. I did wrote an enableM() function together with my disableM() function under "test.xls". So what I did to resolve the problem is to enter the keyboard shortcut for enableM(). But IN CASE there wasn't such command, is there a simpler solution to reset the macro function back to life, without borrowing another pc to create an excel file with enableM() macro



Dave Peterson[_3_]

re-enabling macro under menu item
 
That's one of the pitfalls of screwing with the menus!

I think most would approach it by having the code disable the "print..." option
when that workbook was opened. Then re-enable it when you close the workbook.

You could use your code in the auto_0pen and auto_close procedures in a general
module (or workbook_open and workbook_beforeclose under ThisWorkbook).

But if you want to be nice to your users who have multiple workbooks open, you'd
have to enable the Print option when they changed workbooks. And then disable
it when they came back to yours.

And if excel crashed, it would be nice if you gave them a routine that fixed the
toolbar the way it was before you disabled items.

I know I don't like other workbooks screwing around the stuff I use. Maybe
living with a few wasted sheets of paper (until they learn) would be worth it.

(and don't forget ctrl-P, and print preview, the print icon itself and the
shiftPrintPreview icon all offer other ways to print.)

And if the user disables macros ....

In my opinion, it's just too much effort for the perceived benefit.



jerry h wrote:

A few posts here provide me added knowledge. In one, it mentioned a way to disable "Print option under File", using

CommandBars("Worksheet Menu Bar").Controls("File").Controls("Print...").Enable d = False

Suppose I open a new Excel file. Fire up macro editor and make up one macro with the following variant:
sub disableM()
CommandBars("Worksheet Menu Bar").Controls("File").Controls("Print...").Enable d = False
end sub

I save the Excel file as test.xls. Run the macro. It "works". The macro option has gone. But then how can I get my macro option back? I thought my 'macro option' will be back if I close Excel and reopen Excel. But no, the option doesn't come back. What is the simplest solution (to give the macro function back to the user) IF this was the case?

I am a little bit smarter than the dummies. I do not actually have such a problem because I "forsee" it. I did wrote an enableM() function together with my disableM() function under "test.xls". So what I did to resolve the problem is to enter the keyboard shortcut for enableM(). But IN CASE there wasn't such command, is there a simpler solution to reset the macro function back to life, without borrowing another pc to create an excel file with enableM() macro?


--

Dave Peterson



All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com