Results 1 to 6 of 6

Thread: Change references if missing

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Change references if missing

    Hi,

    I have an Excel VBA file that uses the Microsoft Outlook 10.0 Object Library. The problem I am having is this..... When someone opens the file with a newer version (11.0) of the object library then saves it, then a person with the older version (10.0) opens the file and tries to run the macro it gives them an error because it shows in the references that the 11.0 library is missing. So, you have to go in and uncheck the missing 11.0 library and check the 10.0 library.

    Is there a way to check for missing references in the workbook.open() event and switch the references to the appropriate library through code?

    Any help would be appreciated. Thank you!

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Change references if missing

    This is a known problem. So instead of using Early Binding, use Late Binding and don't set any references. This way the program will still work with both the versions 10 & 11
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Change references if missing

    Late binding example

    instead of:

    Dim xls as Excel.Application

    Dim xls as Object
    set xls = CreateObject("Excel.Application")

    but my guess is this is all in excel right?
    so u are not binding at all...


    well, there was a way to do this , but excel keeps complaining and it wont work...

    anyway...
    put something in the before save event.. to tell users to save as excel 10?

    VB Code:
    1. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    2.    
    3.     End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Change references if missing

    but my guess is this is all in excel right?
    so u are not binding at all...
    he is referencing outlook

    can you late bind like this for ADO too? if so do you need to know which version is installed?

    pete

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Bloomingdale, IL USA
    Posts
    284

    Re: Change references if missing

    Thank you so much! I used the late binding for the outlook reference. I am assuming you could do this for any reference?

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Change references if missing

    yes

    Set objName = CreateObject("Word.Application")
    Set objName = CreateObject("InternetExplorer.Application")
    Set objName = CreateObject("Excel.Application")

    etc...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

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



Click Here to Expand Forum to Full Width