M
martin.j.jung
Hello,
I try to add a context menu to an excel sheet. The problem is that I
can not identify the current commandbar as it seems that this
commandbar is different wether you are in "normal view" or - and
that
is the problem here - you are in "page Break Preview". If the sheet
is
in the normal view the following code works fine, but not if I am in
the "page Break Preview" Mode. I assume the commandbar will even
change if I have a comment in the cell or not and so on ... Is there
a
way to identify the commandbar that will pop up after the
"BeforeRightClick"-Event?
At the moment I have to following code in my worksheet and it works
fine during "normal view" but it does not work during "page Break
Preview"
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
On Error Resume Next
cmdid = Application.CommandBars("Cell").ID
' cmdid = 427
With Application
.CommandBars(cmdid).Controls("Update Work Center in
SAP").Delete
Set cBut
= .CommandBars(cmdid).Controls.Add(Temporary:=True)
End With
With cBut
.Caption = "Update Work Center in SAP"
.Style = msoButtonCaption
.OnAction = "change_workcenter"
.Parameter = Format(Target.value)
End With
On Error GoTo 0
End Sub
I try to add a context menu to an excel sheet. The problem is that I
can not identify the current commandbar as it seems that this
commandbar is different wether you are in "normal view" or - and
that
is the problem here - you are in "page Break Preview". If the sheet
is
in the normal view the following code works fine, but not if I am in
the "page Break Preview" Mode. I assume the commandbar will even
change if I have a comment in the cell or not and so on ... Is there
a
way to identify the commandbar that will pop up after the
"BeforeRightClick"-Event?
At the moment I have to following code in my worksheet and it works
fine during "normal view" but it does not work during "page Break
Preview"
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
On Error Resume Next
cmdid = Application.CommandBars("Cell").ID
' cmdid = 427
With Application
.CommandBars(cmdid).Controls("Update Work Center in
SAP").Delete
Set cBut
= .CommandBars(cmdid).Controls.Add(Temporary:=True)
End With
With cBut
.Caption = "Update Work Center in SAP"
.Style = msoButtonCaption
.OnAction = "change_workcenter"
.Parameter = Format(Target.value)
End With
On Error GoTo 0
End Sub