I am trying to automatically add a reference while running a sub. But I get "User defined-type not defined" for project As VBAProject What's wrong?
Sub tester()
Dim SolverPath As String
SolverPath = Application.LibraryPath & "\SOLVER\SOLVER.XLA"
Dim wb As Workbook
Set wb = ThisWorkbook
Dim project As VBAProject
project = wb.VBProject
wb.project.References.AddFromFile SolverPath
End Sub