Re: dynamic linking/referencing Office libraries

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



NJS <NJS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

How does one dynaically link/reference another Office library. e.g. If an
Access application needs to use the Excel library in VBA code, how do I
dynamically determine which one is installed/available, e.g. Excel 8/9/10/11
etc, and link use the optimal one? (As opposed to hardwired
'Tools/References')

You don't need to create a reference at all. Besides you can't change
references in an MDE. Use late binding instead.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

You'll want to install the reference if you are programming or
debugging and want to use the object intellisense while in the VBA
editor. Then,. once your app is running smoothly, remove the
reference and setup the late binding statements.

Sample code:
' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim objWordDoc As Object
Set objWordDoc = CreateObject(" Word.Document")

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
.



Relevant Pages

  • Re: Access 2000 Find Inbox at Runtime
    ... up the app and not allowing the users in the app at all. ... You'll want to install the reference if you are programming or debugging and want to ... remove the reference and setup the late binding statements. ... Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm ...
    (microsoft.public.outlook.interop)
  • Re: Access 2000 Find Inbox at Runtime
    ... up the app and not allowing the users in the app at all. ... You'll want to install the reference if you are programming or debugging and want to ... remove the reference and setup the late binding statements. ... Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm ...
    (microsoft.public.outlook.general)
  • Re: Access 2000 Find Inbox at Runtime
    ... up the app and not allowing the users in the app at all. ... You'll want to install the reference if you are programming or debugging and want to ... remove the reference and setup the late binding statements. ... Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm ...
    (microsoft.public.outlook.program_vba)
  • Re: Outlook dependency
    ... >like to ship with my installation the libraries, files, OLB's and other ... Late binding means you can safely remove the reference and only have ... an error when the app executes lines of code in question. ...
    (microsoft.public.access.forms)
  • Re: Access2000 db bombing in Access 2002
    ... Use Late Binding then. ... Late binding means you can safely remove the reference and only have ... an error when the app executes lines of code in question. ... Tony Toews, Microsoft Access MVP ...
    (microsoft.public.access.conversion)