Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default automatically load an object library in real time

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default automatically load an object library in real time

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), 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default automatically load an object library in real time

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
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), 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default automatically load an object library in real time

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
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), 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Local Apparent Time (LAT) - real / actual solar time ? Kelvin Excel Worksheet Functions 2 October 25th 09 11:00 AM
Object Library invalid or contains references to object defintions John Excel Programming 1 July 24th 09 11:00 AM
12.0 Object Library Automatically inserted in 2003 VBA markb Excel Programming 0 April 10th 08 12:20 AM
run time error 424 object required - how to load control on Userfo Janis Excel Programming 4 January 17th 08 03:30 PM
Cannot Load Library "LXBCPRP.dll using defualts error 126 mstout2001 Excel Discussion (Misc queries) 0 May 30th 06 12:51 AM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"