Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Local Apparent Time (LAT) - real / actual solar time ? | Excel Worksheet Functions | |||
Object Library invalid or contains references to object defintions | Excel Programming | |||
12.0 Object Library Automatically inserted in 2003 VBA | Excel Programming | |||
run time error 424 object required - how to load control on Userfo | Excel Programming | |||
Cannot Load Library "LXBCPRP.dll using defualts error 126 | Excel Discussion (Misc queries) |