Hi all,
I am creating an Addin for Excel, which prevents the user to delete certain shapes inserted using business logic.
To prevent all possible ways of deleting
1) I remove cut (CommandBarButton) from right click menu on work sheet, add my own CommandBarbutton for cut and handle the click event.
2) I get reference to edit->cut and handle its event.
3) To disable Del , Backspace and Ctrl+X options i use Application.OnKey
'Capture the Delete Key and Call DeletePressed Macro
ExcelApp_Events.OnKey "{DEL}", Procedure:="DeletePressed"
'Capture the Ctrl+C and Call CutPressed Macro
ExcelApp_Events.OnKey "^x", Procedure:="CutPressed"
ExcelApp_Events.OnKey "{BACKSPACE}", Procedure:="BackSpacePressed"
Now the problem with this approach is that you need to write these MACROS on runtime to the excel VBA Project
so i add my own module :
Set WbCodeMod = ExcelApp_Events.ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
WbCodeMod.Name = "NewModule"
and write these macros to them
Q) Is there any other way to fire events of Application.Onkey on my VB side?
This works fine for Office 2000, but for Office XP
To make this concept to work i need to check "Check Trust Access to visual Basic Project" in Macros->Security
which i am not able to do from addin?
Is there any workaround to this?
Please suggest.
Thanks
Rahul