Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Charlie Miller   on Feb 21 In MS Office Category.

  
Question Answered By: Tiaan Thompson   on Feb 21

The following might help.

Sub blah()
'Check whether add-in  installed, if not install  it.
If Not AddIns("Solver Add-in").Installed Then AddIns("Solver
Add-in").Installed = True

'check if menu  item is present, if not add  one.
If Not SolverControlPresent Then
Set MenuItem = CommandBars("Worksheet Menu
Bar").Controls("&Tools").Controls.Add(Type:=msoControlButton)
With MenuItem
.Caption = "Solver (mine)"
.OnAction = "'C:\Program Files\Microsoft
Office\OFFICE11\Library\SOLVER\SOLVER.XLA'!Main"
End With
End If
End Sub


You'll need the SolverControlPresent function to go with that:

Function SolverControlPresent()
SolverControlPresent = False
For Each ctl In CommandBars("Worksheet Menu
Bar").Controls("&Tools").Controls
If ctl.Caption = "Sol&ver..." Then SolverControlPresent = True
Next
End Function

Be aware that I've named my added menu item  "Solver (mine)" to
distinguish it from the existing one I have. Also, the OnAction line
may be a different path on your machine.

To delete any menu items  use the likes of:
CommandBars("Worksheet Menu Bar").Controls("&Tools").Controls("Solver
(mine)").delete
in the immediate pane.

There is a way to place the menu item in the right place within the
dropdown menu but I'm out of time  at the moment.

Share: 

 
 
Didn't find what you were looking for? Find more on Solver add-in menu item disappears Or get search suggestion and latest updates.


Tagged: