View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
programmernovice[_2_] programmernovice[_2_] is offline
external usenet poster
 
Posts: 61
Default Help with VBA script for Excel

On Thursday, December 19, 2019 at 1:38:47 PM UTC-6, Peter T wrote:
"programmernovice" wrote in message
I'm trying to write a script to navigate to the Solver check-box under
References in the Editor. So far I have:

application.sendkeys (%)
application.sendkeys (L)
application.sendkeys (V)

That gets to the VBA Editor.

I cannot figure out how to code the next steps:

Click on "Tools"
Click on "References"
Click in the Solver box.

Any help or suggestion would be appreciated.


I assume you're trying to add a Solver reference to your file..

Dim ref As Object ' Reference
Dim vbp As Object ' VBProject
Dim ad As AddIn

Set vbp = ThisWorkbook.VBProject
On Error Resume Next
Set ref = vbp.References("Solver")
If ref Is Nothing Then
Set ad = Application.AddIns("Solver Add-in")
Set ref = vbp.References.AddFromFile(ad.FullName)
End If

If this for distributing would need more than just this.

Requires trust access to the VBA Project in security settings.

Peter T


Thanks Peter. Purpose is, indeed, to add Solver reference. Is your code to be added to what I started with, or it's the whole thing? I appreciate it.