Hi guys

So I've added the following code into a workbook, which adds a new option on the right-click menu when clicking a cell in column D:

Dim cBut As CommandBarButton
    On Error Resume Next
        With Application
            .CommandBars("Cell").Controls("View Week").Delete
        End With
    On Error GoTo 0

If Target.Column = 4 Then
        With Application
            Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
        End With

        On Error Resume Next
        With cBut
           .Caption = "View Week"
           .Style = msoButtonCaption
           .OnAction = "WkView"
        End With
        On Error GoTo 0
End If
This code works fine whenever I use it in the original file. However, when the file is opened as read-only, when the wkView macro is triggered it tries to open up the writeable version of the file to run the macro from there, and then obviously shows an error to say that the file cannot be opened as a file of the same name is already open. When I step through the wkView macro it works fine. How do I make the onAction event recognise and run the macro in the current workbook?