|
-
May 21st, 2005, 06:41 AM
#1
Thread Starter
New Member
Setting library references
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
-
May 21st, 2005, 08:45 AM
#2
Re: Setting library references
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 21st, 2005, 09:38 AM
#3
Thread Starter
New Member
Re: Setting library references
Could you please elaborate how you could use late binding to avoid a missing reference error ? ---
Thanks
Erlend
-
May 21st, 2005, 09:43 AM
#4
Re: Setting library references
You dont use any reference and declare all your variables as Object.
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
With late binding you loose the intellisense because vb doesnt know the object type.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 21st, 2005, 10:18 AM
#5
Thread Starter
New Member
Re: Setting library references
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???
Thanks in advance....
-
May 21st, 2005, 10:32 AM
#6
Re: Setting library references
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|