View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default automatically load an object library in real time

You can programmatically add the reference with the following code:

Sub LoadInternetLibrary()
On Error Resume Next
ThisWorkbook.VBProject.References.AddFromGuid _
"{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 1, 1
End Sub

The On Error statement causes VBA to ignore the error that would arise
if the library is already referenced.

HOWEVER... If your code declares variables of the types defined within
this library, the code will not compile and thus the code to add the
reference won't get executed. There is really no way to declare
variables whose types are defined in a library that isn't loaded when
the code is written and will not be loaded until run time.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sun, 23 Aug 2009 10:09:29 -0700 (PDT), wrote:

I have read many articles on the same subject but the discussions
about early/late binding are a bit over my head.

I am looking for a simple way to check if the microsoft internet
controls library is loaded and if not load it..

i also noted that at work this library is available (tools-references)
but at home microsoft internet controls does not even show in my list.
(although HTML object library is on the list)

i am using excel 2002

tia