Excel 2003 Context menu handle

  • Thread starter chovatia.jaydeep
  • Start date
C

chovatia.jaydeep

Hi,

I want to hide context menu which appears when we right click on sheet
tab(Excel 2003). This context menu allows us to insert/rename/
delete/... particular worksheet. To get handler of Excel application,
i have written following code:

Please assume that my excel sheet is opened on desktop whose caption
is: "EXCELSHEET_TEST"
------------------------------------------------------------------------------------------------------------
HWND hwndExcelHandler = FindWindow(NULL, "EXCELSHEET_TEST");
------------------------------------------------------------------------------------------------------------

This code successfully returns handle of excel application, but i want
context menu handler(HWND), so that using context menu handle i can
hide it.

Thank you,
Jaydeep
 
D

Dave Peterson

You can disable that menu using regular old VBA:

Option Explicit
Sub auto_open()
Application.CommandBars("Ply").Enabled = False
End Sub
Sub auto_close()
Application.CommandBars("Ply").Enabled = True
End Sub

If macros are disabled, then this won't work. If the users know how to enable
that commandbar, then it won't be secure.

And since this is an application setting, it will affect all workbooks that are
open.

You may want to look at workbook events to disable/enable this menu only under
certain conditions.

Some references:

David McRitchie's intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm
 
C

chovatia.jaydeep

Hi,

I am developing this appliation in C++. So if i get Context menu
handle(HWND) only, then using different Windows APIs like DeleteMenu,
EnableMenu,.....i can hide/disable it.

Is there any way to get handle of Context menu?

Thank You,
Jaydeep
 
D

Dave Peterson

I don't speak C++.

Sorry.

Hi,

I am developing this appliation in C++. So if i get Context menu
handle(HWND) only, then using different Windows APIs like DeleteMenu,
EnableMenu,.....i can hide/disable it.

Is there any way to get handle of Context menu?

Thank You,
Jaydeep
 

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