AccelItem example not working in vb.net

S

Shahzad Godil

I am working on disabling delete accelitem and want my own function which
will be called on KeyUp event for delete. This example is copied from sdk
help and running perfect in vba. But after convering in .net, it is not
working at all.

Please suggest.

Thanks
Shahzad Godil

Public Sub AccelItems_Example()

Dim vsoUIObject As UIObject

Dim vsoAccelTable As AccelTable

Dim vsoAccelItems As AccelItems

Dim vsoAccelItem As AccelItem

Dim intCounter As Integer

'Retrieve the UIObject object for the copy of the built-in menus.

vsoUIObject = Me.AxDrawingControl1.Document.Application.BuiltInMenus

'Set vsoAccelTable to the drawing menu set.

vsoAccelTable =
vsoUIObject.AccelTables.ItemAtID(VisUIObjSets.visUIObjSetDrawing)

'Retrieve the accelerator items collection.

vsoAccelItems = vsoAccelTable.AccelItems

'Retrieve the accelerator item for the Visual Basic Editor.

'To do this, we must iterate through the collection

'and locate the item we want to manipulate.

'The item can be identified either by checking

'the CmdNum property or by checking for the specific key.

'Because checking for the key requires looking at the Alt,

'Control, Shift, and Key properties, it is better to use the

'CmdNum property. Because we retrieved the built-in menus,

'we know that we can find the accelerator.

For intCounter = 0 To vsoAccelItems.Count - 1

If vsoAccelItems.Item(intCounter).CmdNum = VisUICmds.visCmdUFEditClear Then

vsoAccelItems.Item(intCounter).CmdNum = 55

End If





Next intCounter



'Tell Visio to use the new UI.

AxDrawingControl1.Document.SetCustomMenus(vsoUIObject)

MsgBox("done")

End Sub

Private Sub AxDrawingControl1_DocumentOpened(ByVal sender As Object, ByVal e
As AxMicrosoft.Office.Interop.VisOcx.EVisOcx_DocumentOpenedEvent) Handles
AxDrawingControl1.DocumentOpened

Me.AccelItems_Example()

End Sub
 
Top