Code To Load Solver Add-In Automatically

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
Any help would be appreciated...I am using Excel 2007.

My objective is to load an add-in file when you run Excel as an OLE Automation object, without having to load the add-in manually. However, the macro is not loading solver automatically:

Code:
Sub LoadAddIn()
   Dim xl As Object
   ' Activate Microsoft Excel and assign to variable xl.
   Set xl = CreateObject("Excel.Application")
   ' Open the add-in file you want, in this example, Solver.XLAM.
   xl.Workbooks.Open ("C:\Program Files\Microsoft Office\Office12\Library\SOLVER\solver.XLAM")
   ' If you need to register the functions and commands
   ' contained in a resource (XLL), use the RegisterXLL method.
   ' In the example below, all functions of Analys32.xll are
   ' registered.
   ' XL.RegisterXLL "Analys32.xll"
   ' Run any auto macros contained in the add-in file
   ' Auto macros don't run when you open a file
   ' using the Open method.
   xl.Workbooks("Solver.xlam").RunAutoMacros 1
   Set xl = Nothing
 End Sub

Source for code: http://support.microsoft.com/kb/213489/
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Andrew are you suggesting the following will work?:

Code:
Sub LoadAddIn()
   Dim xl As Object
      Set xl = CreateObject("Excel.Application")
      xl.AddIns("Solver Add-in").Installed = True
End Sub

If so I am still getting an error '1004' it is still not recognizing that the solver add-in has been added automatically.

Please let me know if I am missing something...

However, I do appreciate the fast response.
 
Upvote 0
This worked for me when run from Word 2003 while Excel 2003 wasn't open:

Code:
Sub LoadAddIn()
    Dim xl As Object
    Set xl = CreateObject("Excel.Application")
    xl.AddIns("Solver Add-in").Installed = True
    xl.Visible = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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