Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Dec 2001
    Location
    Cromwell, Connecticut, USA
    Posts
    40
    Thanks
    2
    Thanked 2 Times in 2 Posts

    MSWord14.olb Reference Error

    Hi All,

    I have an Excel 2003 macro that contains an Access and Word reference (both 11.0). It opens fine in Excel 2010 and saves normally, as a 97-2003.xls, in Excel 2010. Once opened again in Excel 2003, it generates an error saying that the MSWord.olb (14.0) is missing. All references switch from their 11.0 library (2003) to the 14.0 library (2010) when opened in Excel 2010 (SP1). The problem is when opening again in Excel 2003 (SP3), all library references revert to the correct 11.0 except the MSWord reference, which stays as the 14.0 level.

    Has anyone experienced this and know how to fix it?

    Thanks - John

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,158
    Thanks
    200
    Thanked 781 Times in 715 Posts
    John,

    This is a normal problem when using different versions of Office products and Early Binding. The way around this problem is to use Late Binding in your VBA code. Here is a MS Article on the subject. The advantage of early binding is in coding when you are supplied a list of properties/methods when you hit the . following an object. The advantage of late binding is that it will pick up the correct link libraries from the machine/office version it is running on. Here's a sample of code that let's you switch between early/late binding for development/execution.

    Note:
    Set Compiler Constant for Early/Late Binding conditional code
    '0 = Early Binding
    1 = Late Binding

    Set in Tools->Project Properties... Global Scope if set here
    For Module Scope use
    #Const LateBinding = [0|1]

    Object Declaration:
    Code:
    #If LateBinding = 0 Then    'Early Binding
       Dim appOL      As Outlook.Application
       Dim miMail     As Outlook.mailitem
    #Else
       Dim appOL      As Object
       Dim miMail     As Object
    #End If
    Object Initiation Example:
    Code:
    #If LateBinding = 0 Then
           Set miMail = appOL.CreateItem(olMailItem)  '*** olMailItem = 0 ***
    #Else
           Set miMail = appOL.CreateItem(0)
    #End If
    The rest of the code is the same in either case.

    HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    kamski (2013-11-03)

  4. #3
    Lounger
    Join Date
    Dec 2001
    Location
    Cromwell, Connecticut, USA
    Posts
    40
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Thanks RG! I was actually late binding in my code but I had the MSWord library enabled in the Excel 2003 references. Disabling the reference fixed the error.

Posting Permissions

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