Is there a way to set the library references with VBA code? That is I do not want the user to get an error message just because he/she has not checked the appropriate library in the reference list.
??
Erlend
Printable View
Is there a way to set the library references with VBA code? That is I do not want the user to get an error message just because he/she has not checked the appropriate library in the reference list.
??
Erlend
Welcome to the Forums.
Nope, not that I know as the VBA Editor will disable the References menu when accessed by code.
You could use late binding instead.
Could you please elaborate how you could use late binding to avoid a missing reference error ? ---
Thanks
Erlend
You dont use any reference and declare all your variables as Object.
With late binding you loose the intellisense because vb doesnt know the object type.VB Code:
Private Sub command1_click() 'Early binding... Reference required. Dim oAppEarly as Excel.Application 'Late binding... No reference Dim oAppLate as object set oAppEarly = New Excel.Application set oAppLate = CreateObject("Excel.Application") '... '... End Sub
Okey I think I understand this in theory but can you explain how I can use this approach with the solver library?
That is I want the following code to work without setting a reference...
Sub Makro1()
' Works fine when I have a reference to the SOLVER library
SolverOk SetCell:="$B$16", MaxMinVal:=1, ValueOf:="0", ByChange:="$B$16"
SolverSolve
End Sub
I can't seem to create a solver object where these methods are found??? :sick:
Thanks in advance....
Thats a tough one. Try looking in the registry under the HKEY_CLASSES hive for the entry of Solver.????
You can usually find info on a references objects/props/methods by using the Object Browser in the VBA IDE. Press F2 while viewing the IDE.