I have the following VBA code that works great in Excel 2013 (Win) but when I try to use it on Excel 2011 (Mac) the workbook tries to reopen and I receive errors. Is there any way to modify this code to work on the 2011 version?
The code uses the BeforeRightClick event handler to show a list of sub procedures if I right click on column C. When I use it on the Mac the menu shows but when I click on any of the subs it restarts excel. However, this works great in Windows so I don't know what I need to do different on Mac.
Any help would be so appreciated! Office 2014 for Mac can't come fast enough!!
The code uses the BeforeRightClick event handler to show a list of sub procedures if I right click on column C. When I use it on the Mac the menu shows but when I click on any of the subs it restarts excel. However, this works great in Windows so I don't know what I need to do different on Mac.
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) If Not Intersect(Target, Range("C:C")) Is Nothing Then
Cancel = True
Dim varCaption As Variant, varAction As Variant, i As Integer
Dim objMenu As CommandBar, objCommand As CommandBarControl
' Create array of shortcut menu captions.
varCaption = Array("Milestone", "Deliverable", "Info", "Check", "Reset", "---------", "Hide Empty Rows", "Unhide Empty Rows", "Hide Completed Tasks", "Unhide Completed Tasks", "Unhide All Rows", "---------", "Insert Row Below", "Delete Selected Row(s)")
' Create array of the Sub procedure names to call from shortcut menu.
varAction = Array("Milestones", "Deliverables", "Info", "Check", "Clear", "--", "HideEmptyRows", "UnhideEmptyRows", "HideCompleteTasks", "UnhideCompleteTasks", "UnhideAllRows", "--", "InsertRow", "DeleteRow")
' Add shortcut menu to CommandBars collection.
Set objMenu = CommandBars.Add(Position:=msoBarPopup, Temporary:=True)
' Loop through arrays to add commands to shortcut menu.
For i = 0 To UBound(varAction)
Set objCommand = objMenu.Controls.Add
objCommand.Caption = varCaption(i)
objCommand.OnAction = varAction(i)
Next i
' Display shortcut menu.
objMenu.ShowPopup
' Cancel display of the built-in shortcut menu.
Cancel = True
End If
End Sub
Any help would be so appreciated! Office 2014 for Mac can't come fast enough!!