Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right click menu problem

Status
Not open for further replies.

HorseGoose

Programmer
Apr 24, 2003
40
GB
I have code throughout my program which customises the right click context menu. It has always worked fine.

In one sheet however it works until another event happens, then after that it doesn't wok any more.

I have used the debugger to see if it was running the code, and indeed it does. It runs all the code but at the end does not display the right click menu.

I have looked at application.screenupdating to ensure it is set to true. I have no idea why it would work then stop after another event has occured.

Has anyone ever had this problem? It could be because I am so close to it I cannot see the obvious.

I attach the code underneath for reference.

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim varbefore As Integer
Dim varcell As Object

varbefore = 1

CommandBars("cell").Reset
For Each varcell In Application.CommandBars("cell").Controls
varcell.Delete
Next varcell

With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.Caption = "hide unused lines"
.OnAction = "hide_rows"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.Caption = "unhide unsed lines"
.OnAction = "unhide_rows"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.Caption = "make Technical - Master Pack Copy"
.OnAction = "mpc_print"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.BeginGroup = True
.Caption = "reset master pack copy"
.OnAction = "check_mpc_reset"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.Caption = "load master pack copy from another project"
.OnAction = "check_mpc_load"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.BeginGroup = True
.Caption = "jump back to nutritional calculations"
.OnAction = "jumpnutrition"
End With
varbefore = varbefore + 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.Caption = "jump to main beverage"
.OnAction = "jumpmain"
End With
varbefore = varbefore + 1

Select Case ActiveWorkbook.Windows.Count
Case Is > 1
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.BeginGroup = True
.Caption = "close ingredients list tool"
.OnAction = "split_close"
End With
varbefore = varbefore + 1
Case Else
With Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=varbefore, Temporary:=True)
.BeginGroup = True
.Caption = "load ingredients list tool"
.OnAction = "split_load"
End With
varbefore = varbefore + 1
End Select

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top