Sub AddMenuItem()
Dim ViewMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton
Set ViewMenu = CommandBars(1).FindControl(ID:=30004)
If ViewMenu Is Nothing Then
MsgBox "Cannot add menu item."
Exit Sub
Else
Set NewMenuItem = ViewMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "&GridLines"
.OnAction = "yourActionOrMacro"
End With
End If
End Sub