Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set reference 'on the fly' (WinXP/Word2003 NL)

    I need to reference the dll C:Program FilesGeneraliBox.dll from a global template. No problem doing so at design time. But that means distribution of the dll to all users (1000+) of the global template. And the dll is only used by the 3 percent of the users with acces to a particular application. So I wonder if it is possible to set the reference "on the fly" when Word starts (module AutoExec, Sub Main in the global template), depending on the existence of that dll on the PC.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    If you set a reference to the Microsoft Visual Basic for Applications Extensibility 5.3 library, you can manipulate references in code. Put the following macro in a module; you can run it to test if it works correctly, and if so, you can call it from the AutoExec macro.

    Sub TestRef()
    Const strLib = "C:Program FilesGeneraliBox.dll"
    If Not Dir(strLib) = "" Then
    ThisDocument.VBProject.References.AddFromFile strLib
    End If
    End Sub

  3. #3
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    Thanks Hans, I'll give that a try.

  4. #4
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    <P ID="edit" class=small>(Edited by JanB on 14-Jul-05 10:26. edited some typo's and added note)</P>The code works fine, but that's not enough to solve the problem. Removing the manually applied reference to the ibox.dll is causing a "Compile error in a hidden module" right at the start of Word. Delving into the code of a co-worker who is now on vacation, I learned that the cause is a line "Public gcDFC As New DfExSession" in the declarations section of a module (DFC = Documentum Foundation Class; Documentum is a document management system).
    So I'm trying to switch from this early binding to late binding by replacing the declaration line with "Public gcDFC As Object" and in Sub Main adding the line "gcDFC = CreateObject("iBox"), but that fails with "Error 429, ActiveX-component cannot create object" (something like this, translated from Dutch). iBox is the name with which the dll presents itself in the Tools | Reference... dialog. As I'm not very familiar with this late binding, I'm stuck. What am I doing wrong?

    Note
    As I understand it, iBox is a sort of "communications layer" between VBA en DFC, also containing routines to add, edit & delete registry settings in the Documentum brache.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    If the early binding declaration is Public gcDFC As New DfExSession, the late binding equivalent is

    Public gcDFC As Object
    Set gcDFC = CreateObject("iBox.DfExSession")

    or perhaps

    Set gcDFC = CreateObject("DfExSession")

    You must change all declarations of objects associated with the iBox library to As Object.

    Also look out for symbolic constants defined in the iBox library, you must replace them with their values.

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    Boy, are you fast!
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  7. #7
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    I still cannot get this to work. Steps taken:
    - I made sure the dll is registered. I found it in the Registry under HKEY_CLASSES_ROOTCLSID{number}. In key ProgID, (Standard) has value iBox.DfExSession.
    - In a standard module, I put the declaration Public gcDFC As Object
    - In module AutoExec, Sub Main, I check if the iBox.dll is present in the correct path
    - If so, the line Set gcDFC = CreateObject(iBox.DfExSession) is executed
    - all code referring to gcDFC is in the Sub cmdOK_Click of a simple form with two textboxes to input username and password and an OK button
    - this form is only shown if the iBox.dll is present (only a few users, including my developer-PC)

    The line Set gcDFC = CreateObject(iBox.DfExSession) causes runtime error 438: "This property or method is not supported by this object". Any ideas?

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    Is the lack of quotes around iBox.DfExSession in Set gcDFC = CreateObject(iBox.DfExSession) just a typo?

  9. #9
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set reference 'on the fly' (WinXP/Word2003 NL)

    Oops, not a typo... <img src=/S/blush.gif border=0 alt=blush width=15 height=15> <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>
    Sometimes I appear to be completely blind for those little things. Thanks Hans!

Posting Permissions

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