Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Menu commands - overruling with macro - How to do it?

If I make a procedure like this in word:

Sub FilePrint()
MsgBox "hello"
End Sub

it will overule the normal File - Print menu command and the same goes for
alle the menu commands.

How do I accomplish the same in Excel. I tried with the above code in a
module, ThisWorkbook module and in a Sheet module.

am I doing someting wrong, or does it simply not work in Excel.

Jan




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Menu commands - overruling with macro - How to do it?

Jan,

In the codemodule of the ThisWorkbook object:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
FilePrint
End Sub

Put your FilePrint code into a standard module in the same workbook.

HTH,
Bernie
MS Excel MVP

"Jan Kronsell" wrote in
message ...
If I make a procedure like this in word:

Sub FilePrint()
MsgBox "hello"
End Sub

it will overule the normal File - Print menu command and the same

goes for
alle the menu commands.

How do I accomplish the same in Excel. I tried with the above code

in a
module, ThisWorkbook module and in a Sheet module.

am I doing someting wrong, or does it simply not work in Excel.

Jan






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Menu commands - overruling with macro - How to do it?

I know how to use events, that will only work if a suiting wevent exist. The
FilePrint was just an example. It migh as well have been FormatColumn or
InsertRow or any other built in commands.

I also know I can edit the menu item so it plays a macro, whwen selected,
but that will not prevent user from accessing the original function by using
a shortcut.

What I really need is to make my own function for fx saving a file, and make
that the only way to save a file (in a specific workbook).

Jan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Menu commands - overruling with macro - How to do it?

Jan,

What I really need is to make my own function for fx saving a file,

and make
that the only way to save a file (in a specific workbook).


As in my example, use the Workbook's BeforePrint event for this, in
the specific workbook.

Other than that, you can try to intercept all the commands and
override all the shortcuts, but you'll have a bunch of angry users.
Search the Google groups to find examples - none are foolproof.

HTH,
Bernie
MS Excel MVP





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Menu commands - overruling with macro - How to do it?

Thanks. I'll look into it.

Jan

"Bernie Deitrick" skrev i en meddelelse
...
Jan,

What I really need is to make my own function for fx saving a file,

and make
that the only way to save a file (in a specific workbook).


As in my example, use the Workbook's BeforePrint event for this, in
the specific workbook.

Other than that, you can try to intercept all the commands and
override all the shortcuts, but you'll have a bunch of angry users.
Search the Google groups to find examples - none are foolproof.

HTH,
Bernie
MS Excel MVP









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of Excel Menu Commands Alex Excel Discussion (Misc queries) 2 December 29th 08 11:06 PM
Reset sheet tab menu commands Sparky13 Excel Discussion (Misc queries) 3 October 23rd 07 09:31 PM
How do I hide certain commands in a drop-down menu? Tatoo_Me Excel Discussion (Misc queries) 2 March 3rd 06 11:41 PM
Lost my menu bar commands pod Excel Discussion (Misc queries) 3 April 29th 05 12:52 AM
menu commands are gray kcohio Excel Discussion (Misc queries) 1 December 5th 04 07:56 PM


All times are GMT +1. The time now is 02:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"