PC Review


Reply
Thread Tools Rate Thread

automatically load an object library in real time

 
 
dtshedd@yahoo.com
Guest
Posts: n/a
 
      23rd Aug 2009
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
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      23rd Aug 2009
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), (E-Mail Removed) 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

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      23rd Aug 2009
the DLL name for the library is IEFRAME.DLL. Yo can use this code to check
if the library is loaded.

Sub checkLibrary()

found = False
For Each lib In Application.VBE.ActiveVBProject.References
BaseName = lib.fullPath
BaseName = Mid(BaseName, InStrRev(BaseName, "\") + 1)
BaseName = UCase(BaseName)
If BaseName = "IEFRAME.DLL" Then
found = True
Exit For
End If
Next lib
If found = True Then
MsgBox ("Library IEFRAME.DLL was loaded")
Else
MsgBox ("Library IEFRAME.DLL was not loaded")
End If


"Chip Pearson" wrote:

> 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), (E-Mail Removed) 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

>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      23rd Aug 2009
Joel,

That is a fine, but the assumption is that the user wants to actually
use the library, not merely have a reference to it. And that implies
that there will be variables declared that are defined in the library.
Prior to running the CheckLibrary function, the compiler will choke on
any variables whose type is defined in the (presently unreferenced)
IEFRAME.dll.

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 13:21:01 -0700, Joel
<(E-Mail Removed)> wrote:

>the DLL name for the library is IEFRAME.DLL. Yo can use this code to check
>if the library is loaded.
>
>Sub checkLibrary()
>
>found = False
>For Each lib In Application.VBE.ActiveVBProject.References
> BaseName = lib.fullPath
> BaseName = Mid(BaseName, InStrRev(BaseName, "\") + 1)
> BaseName = UCase(BaseName)
> If BaseName = "IEFRAME.DLL" Then
> found = True
> Exit For
> End If
>Next lib
>If found = True Then
> MsgBox ("Library IEFRAME.DLL was loaded")
>Else
> MsgBox ("Library IEFRAME.DLL was not loaded")
>End If
>
>
>"Chip Pearson" wrote:
>
>> 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), (E-Mail Removed) 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

>>

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      24th Aug 2009
I just showed code how to determine if the library was selected as a
reference. I assumed that your code would be used to add the library if
Found was false. I just want to show tia that you can get all the defined
references in VBA.

"Chip Pearson" wrote:

> Joel,
>
> That is a fine, but the assumption is that the user wants to actually
> use the library, not merely have a reference to it. And that implies
> that there will be variables declared that are defined in the library.
> Prior to running the CheckLibrary function, the compiler will choke on
> any variables whose type is defined in the (presently unreferenced)
> IEFRAME.dll.
>
> 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 13:21:01 -0700, Joel
> <(E-Mail Removed)> wrote:
>
> >the DLL name for the library is IEFRAME.DLL. Yo can use this code to check
> >if the library is loaded.
> >
> >Sub checkLibrary()
> >
> >found = False
> >For Each lib In Application.VBE.ActiveVBProject.References
> > BaseName = lib.fullPath
> > BaseName = Mid(BaseName, InStrRev(BaseName, "\") + 1)
> > BaseName = UCase(BaseName)
> > If BaseName = "IEFRAME.DLL" Then
> > found = True
> > Exit For
> > End If
> >Next lib
> >If found = True Then
> > MsgBox ("Library IEFRAME.DLL was loaded")
> >Else
> > MsgBox ("Library IEFRAME.DLL was not loaded")
> >End If
> >
> >
> >"Chip Pearson" wrote:
> >
> >> 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), (E-Mail Removed) 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
> >>

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically load solver reference library Greg Snidow Microsoft Excel Programming 4 29th Sep 2009 11:59 PM
12.0 Object Library Automatically inserted in 2003 VBA markb Microsoft Excel Programming 0 10th Apr 2008 12:20 AM
Automatically duplicating contents of one table row into another in real time? Ed Chilada Microsoft Word Document Management 2 16th Mar 2008 02:38 PM
Load ref libraries in real-time =?Utf-8?B?RGFuaWVs?= Microsoft Access VBA Modules 1 4th Oct 2007 11:26 PM
Automatically saving records in real time Helen Microsoft Access Form Coding 1 4th May 2004 08:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:18 PM.