Modify VBA for Excel 2011 for Mac

justm0n3y

New Member
Joined
Feb 18, 2014
Messages
1
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.

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!!
 
Can you provide an example workbook that works in 2013 but not in 2011?
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top