Results 1 to 10 of 10

Thread: VBA referring to external shared Libraries, 1) Early, 1.5) Laterly Early and 2) Late Binding Techniques

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,451
    Rep Power
    10

    VBA referring to external shared Libraries, 1) Early, 1.5) Laterly Early and 2) Late Binding Techniques

    See here for examples of how to bind specific Libraries: http://www.excelfox.com/forum/showth...ll=1#post10970

    VBA referring to external shared Libraries, 1) Early, 1.5) Laterly Early and 2) Late Binding Techniques


    I have been doing things like this a bit Lately, or more often Early, Laterly, and I got a bit confused: One usually hears of the two ways, Early and Late Binding, but then when one actually comes to “do it” you see that there are a few ways based on those two basic ways..
    So I wrote myself some notes and thought I would share them.

    Background. What is a “Library” in VBA
    If you are happy with what you think is a Library and have a vague idea about Early and Late Binding in VBA, and / or maybe have used the “libraries available in a VBA code” one once or twice, and/ or are not too bothered with the background ideas, then you might want to skip this post.
    You don’t need to know it and I am probably a bit wrong with some of the things as I made most of it up from inspired guessing and listening to the best experts who mostly don’t know what they are talking about.
    Shared Libraries
    Quite often in computing, and certainly in Windows, different software packages share stuff. This can go loosely under the term of shared libraries , but Libraries in this sense is not quite ( yet – maybe a bit laterly at runtime ) our Libraries

    Background . The End Goal. What are we trying to do?
    In many cases what we finally want to do is have an object variable in our coding which can be used in similar ways to one of the large standard available VBA objects.
    As a simple explanation: Imagine you wanted to use the range object, but for some reason is was not available in the standard VBA library. ( The standard VBA library is one of ( usually 4 ) such libraries that is always made available by default). If it wasn’t available in the standard libraries, then it very likely would be in one the massive amount of additional libraries available. What Binding does is organises that you have any additional Libraries available to a code. Typically then from those you could organise to have an object from it in your code. That is usually the end goal: To have an object, ( or possibly a few ) in your code that is in one of the additionally “available to VBA Libraries”

    Linking and Embedding Component Model Object, LECMO
    I think maybe about 25 years ago Microsoft tried to
    _ a) get in early and make it difficult for anyone else to do anything,
    and they
    _ b) tried to confuse anyone trying as well with poor choice of words.

    _ a) Things were organised so that they could be Linked and Embedded , and a bit later that lead to Models of how Components needed to be. So all were forced into making sure interfaces fitted.
    _b) the word Object was thrown in to confuse with the word used in Object Orientated Programming which is not quite meant to be the same, well maybe Laterly later.
    The end result is some technology named as Object Linking and Embedding and then the Component Object Model
    The idea of the COM is that things ( objects ) can implement their functionality through the interfaces.
    In the meantime everyone forgot what actually went on and the OLE is often referred to as the later stuff coming from the COM stuff. The word OLE is more likely used to describe something when you are not quite sure what it is you are talking about.
    Maybe at the time, OLE had some thing to do with something understandable like making a simple copy and paste work between different things. But as the workings of the clipboard puzzle some of the best computer experts , then even that is suspect. If you want to try and look at COM as some logical progression from OLE, then you could think of that allowing say an Excel Worksheet to be in a Word document without ever opening the Excel application. You could also think of something disgusting, as I just did, if you want to. That might be just as relevant to the discussion at hand.
    Previous to all this , and more classically in computing , a compilation, that is to say production of a final runable lower level computer program, would have the complied equivalents of copies of all the things ( functions ) from the shared libraries.
    However the COM and OLE technologies allow for files which are effectively runable allowing a link at runtime to required functions. These functions are typically, ( but not always ) held in Folders or Files with the .dll extension.
    The former case (“ “static” link libraries “ ) could lead to a duplication of complied functions.
    This basic idea was then found to be useful do more pseudo real time things – allowing interaction , for example with things in the internet. Without this technology, you could, to a first approximation expect to have to pseudo download a lot previously and store , and possible re organise it, such that a running code could use things from the source
    ActiveX Bollox
    Parallel to the LECMO technologies, or partially developed from it, where technologies optimised for internet use. This goes by the name of ActiveX.
    In fact you will find that the word ActiveX can almost be used for many things and usually is when the person may know what he is talking about but can’t easily explain it. It is like using expressions like “this shit” or “that bollox” in normal conversations, an “ActiveX crap” would be equivalent to the former two expressions. Bollox = crap = shit = ActiveX to a first approximation
    In fact, the object, which having available is our final goal, can be referred to as an ActiveX object.
    Although it was optimised for internet “communication” of functionalities, it more or less took over the computer control generally.
    Most things then are somehow controlled by these things.
    In fact this developed into a cancerous type growth into the whole computer system: Visual Basic provides polymorphism (polymorphism : here approximately the ability to do slightly different variations of the same thing using the same basic instructions, like a universal control Button should be possible to make which on the view of different uses in different situation does a very similar thing, but “behind the interface” might be a lot of stuff to make that button universal ) through these multiple ActiveX interfaces. In the Component Object Model (COM) that forms the infrastructure of the ActiveX specification, multiple interfaces allow systems of software components to evolve and break existing code. ……. In this sense interface is a set of related properties and methods. Much of the ActiveX specification is concerned with implementing standard interfaces to obtain system services or to provide malfunctionality to other programs. It allows for the possibility , for example, for updates to break things.

    “VBA available Libraries” of things available to us, “application ( Excel ) programmers”
    We might be loosely called “application ( Excel ) programmers”.
    We, as application programmers, can access directly or indirectly a lot of the software used to create the application in the first place . ( A running or “open” Excel is often referred to as an application, or the Excel application. I suppose it is talking about the software being applied ). The term “Application Programmes Interface” as well as expressions of the form us “having access to the Dynalic ( or direct ) Link Libraries” are loose and intimidating term used, amounts other things, generally to us referencing the runable files held often , but not always, in Folders or files with the letters ddl in their names.
    Broadly speaking we can get at them in two different ways summarised below. In simple terms we set a fixed reference or path or route to get at the tools at runtime

    Using one or more dlls in a VBA code
    The basic fundamental singular case,
    It is possible to get at a specific single or a few similar dll files function runable things.. To do this in VBA code an initial code line something similar to a Dim code line is done. This is a Declare type code line at the top of a code module. After that an “API Function” is used in a code similar to a normal VBA Function
    ( For example http://www.excelfox.com/forum/showth...tion#post10465 ).

    Our aim is to get at a lot of those functions, those related to some common “thing”, as well as possibly a few other things. In simple terms, the Libraries we are talking about are an attempt to organise in what might be typically required collections of those functions and other things, such as some additional coding that might use a few of those things

    Libraries available to VBA
    We are talking basically about these things:
    1 Tools 2 referrences 3 Scroll Find Check.JPG . https://imgur.com/jyLjdBb
    1 Tools 2 referrences 3 Scroll Find Check.jpg#

    The word Library is used sometimes like Object a bit loosely to help contribute to the Obfuscation technology used in most of the things being discussed here.
    The word Library is used often when use of dll stuff is bundled up into something like a collection of Functions and other stuff that include things that use one or more of similar dlls or use dlls that do similar stuff. This is organised something like a Visual Basic Class Object, ( An example of such a Class Object is a VBA Class Object called Worksheet ) with the available Methods Properties Constants and Functions etc which can be made available to any VBA code. The collection goes by the name of a Libraray. Specifically it is one of those Libraries that you often hear about as requiring a check against in the way of … “…… -- VB Editor -- Tools ---- references --- scroll down and check the appropriate library from the massive list of those available….”……
    As far as in VBA is concerned, the aim is to have the available “API ddl” stuff available in a code via a Object.
    Often instead of calling these things Libraries they are referred to themselves as an API. So one can see that the term is used in a very loose Obfuscation type way.
    It is the way of getting access in a code to this second larger group of tools that is concerned with the Terms Late, Early Late, and Late Binding.
    The end result is having access to the tools in an Object Orientated Programming way such as we would everything else in our code. Indeed if you look initially at the checked items in the list, you will always see a few default libraries checked.
    The checked things are to some extent intuitive as being reasonable in the first place for our codes to have any chance of working. In particular the Visual Basic For Applications is a direct example of a “Libraries available to VBA”. You can in fact add an extra VBA. at the start of many code lines to completely explicitly reference the library to be sure you are accessing the Visual Basic For Applications library.****
    The start point of getting access to other libraries in a code will be therefore to organise that we have objects variables in our code which similarly can be accessed in code via:

    ___= ThatLibraryObject.StufffromItIWant

    _._______________________
    Last edited by DocAElstein; 06-03-2024 at 03:26 PM.

Similar Threads

  1. Understanding VBA Range Object Properties and referring to ranges and spreadsheet cells
    By DocAElstein in forum Familiar with Commands and Formulas
    Replies: 3
    Last Post: 01-25-2017, 04:55 AM
  2. Combobox Not Working In Excel Workbook Shared Mode
    By peter renton in forum Excel Help
    Replies: 15
    Last Post: 06-03-2013, 01:25 PM
  3. Debugging Techniques in VBA
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-23-2013, 07:27 AM
  4. Get External Data Error
    By marreco in forum Excel Help
    Replies: 2
    Last Post: 01-05-2013, 08:20 PM
  5. Class Objects Created Using the CreateObject Method That Employs Late Binding
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 08-16-2011, 12:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •