none
missing or broken reference to the file 'MSWORD.OLB' version 8.7 RRS feed

  • Question

  • Hi guys,
    I Need Some Help 

    I use this code to fill a word document with records from a access form:

    Option Compare Database
    Private Sub Command14_Click()
    Call fillwordform
    End Sub
    
    
    Function fillwordform()
    Dim appword As Word.Application
    Dim doc As Word.Document
    Dim Path As String
    
    On Error Resume Next
    Error.Clear
    Path = "C:\Users\Home\Desktop\Print.docx"
    Set appword = GetObject(, "word.application")
    If Err.Number <> 0 Then
    Set appword = New Word.Application
    app.Word.Visible = True
    End If
    Set doc = appword.Documents.Open(Path, , True)
    With doc
        .FormFields("Text1").Result = Me.Field1
        .FormFields("Text2").Result = Me.Field2
        .FormFields("Text3").Result = Me.Field3
        End With
    appword.Visible = True
    appword.Activate
    
    Set doc = Nothing
    Set appword = Nothing
    
    
    End Function

    The project was made on my home pc using Office 2016 and works fine but when a try to run the code on my pc from work i get this error: "Your Microsoft Access database or project contains a missing or broken reference to the file 'MSWORD.OLB' version 8.7"

    On pc from work I have word 2013 and access runtime 2013.

    • Edited by Ricanos Wednesday, March 30, 2016 3:56 PM
    Wednesday, March 30, 2016 3:54 PM

Answers

  • >>>The project was made on my home pc using Office 2016 and works fine but when a try to run the code on my pc from work i get this error: "Your Microsoft Access database or project contains a missing or broken reference to the file 'MSWORD.OLB' version 8.7"

    On pc from work I have word 2013 and access runtime 2013.<<<

    According to your description, I suggest that you could consider using late binding, if you want to support multiple versions of Office.

    For more information, click here to refer about Using early binding and late binding in Automation

    • Marked as answer by David_JunFeng Thursday, April 7, 2016 9:11 AM
    Thursday, March 31, 2016 3:21 AM
  • As David has mentioned, the way to avoid these things is to use Late Binding. Late Binding allows you to ignore the "version" of the library on the target machine, and have your code use whatever is available on that machine.

    There are caveats to using late binding, however:

    • You don't get Intellisense, which can be very, very helpful during development
    • You must still be aware of the "lowest" version of the library your users will have installed, since you cannot use any feature that will not be available in that "lowest version". For example, if you're developing with the Version10 library, and you use CoolNewFeature1 (which was introduced in Version10), your code will fail if you deploy to a machine running Version9.
    • You must be sure to not use constants that are only available in the bound library, and instead either (a) declare your own constants to match the ones in the library or (b) use the "value" of that constant. Both can lead to issues, so you must decide how to approach that with care.
    • Code can sometimes be more difficult to read and maintain.
    • Early-bound code generally runs faster

    Many developers use Early Binding during development and then change their code to Late Binding just before deployment.

    Finally, note that if you DO use Late Binding, be sure to remove the reference before you ship you app to the end users.


    -- Scott McDaniel, Microsoft Access MVP

    • Marked as answer by David_JunFeng Thursday, April 7, 2016 9:11 AM
    Thursday, March 31, 2016 3:46 PM

All replies

  • >>>The project was made on my home pc using Office 2016 and works fine but when a try to run the code on my pc from work i get this error: "Your Microsoft Access database or project contains a missing or broken reference to the file 'MSWORD.OLB' version 8.7"

    On pc from work I have word 2013 and access runtime 2013.<<<

    According to your description, I suggest that you could consider using late binding, if you want to support multiple versions of Office.

    For more information, click here to refer about Using early binding and late binding in Automation

    • Marked as answer by David_JunFeng Thursday, April 7, 2016 9:11 AM
    Thursday, March 31, 2016 3:21 AM
  • As David has mentioned, the way to avoid these things is to use Late Binding. Late Binding allows you to ignore the "version" of the library on the target machine, and have your code use whatever is available on that machine.

    There are caveats to using late binding, however:

    • You don't get Intellisense, which can be very, very helpful during development
    • You must still be aware of the "lowest" version of the library your users will have installed, since you cannot use any feature that will not be available in that "lowest version". For example, if you're developing with the Version10 library, and you use CoolNewFeature1 (which was introduced in Version10), your code will fail if you deploy to a machine running Version9.
    • You must be sure to not use constants that are only available in the bound library, and instead either (a) declare your own constants to match the ones in the library or (b) use the "value" of that constant. Both can lead to issues, so you must decide how to approach that with care.
    • Code can sometimes be more difficult to read and maintain.
    • Early-bound code generally runs faster

    Many developers use Early Binding during development and then change their code to Late Binding just before deployment.

    Finally, note that if you DO use Late Binding, be sure to remove the reference before you ship you app to the end users.


    -- Scott McDaniel, Microsoft Access MVP

    • Marked as answer by David_JunFeng Thursday, April 7, 2016 9:11 AM
    Thursday, March 31, 2016 3:46 PM