• Microsoft DAO 3.6 Object Library (word 97, word 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Microsoft DAO 3.6 Object Library (word 97, word 2000)

    Author
    Topic
    #392951

    I am using DAO to connect to a database. I used WOrd 2000 to create my macros etc( i checked the Microsoft DAO 3.6 Object Library in the References menu item ) . When i tried to use the macros in Word 97, it gave me an error. SO, i tried to compile my macros in Word 97, but I could not. What should i do in order to be able to run the macros in both Word 2000 and Word 97?

    Thanks in advance….

    Viewing 5 reply threads
    Author
    Replies
    • #709262

      DAO 3.6 is the version for Office 2000/2002. In Office 97, the correct version is 3.5 or 3.51.

      If you open the document/template in Word 97 and set a reference to the 3.5 or 3.51 library, the code should work there, and the reference will probably update itself when the document/template is opened in Word 2000. This only works when going to a higher version.

      • #710050

        1. If i have a template that uses the Microsoft DAO 3.51 Object library in it, what are the minimum requirements needed for it to run on another PC that has Word 97 or Word 2000? I noticed that the template works correctly on “some” WOrd 2000 Pcs and not all. On the ones it does not work on it gives me runtime error 429 : ActiveX component can’t create object. thsi error message occurs at teh command where I am trying to “OpenDatabase”.

        2. If i want a template to work on both Word 97 and 2000 and uses DAo objects, is it ok to compile the template In Word 97 and it will work on 2000? Am i doing this the right way?

        Thanks…

        Thanks..

        • #710198

          When you have the problem on a Word 2000 PC, open the Tools>References dialog and see if you have MISSING there. This would indicate that you cannot simply rely on VBE to “bump up” the DAO library to the next version and you have to use a strategy like one of my examples above. If you don’t have a MISSING, consider the issue pieter raises about the file format.

        • #710199

          When you have the problem on a Word 2000 PC, open the Tools>References dialog and see if you have MISSING there. This would indicate that you cannot simply rely on VBE to “bump up” the DAO library to the next version and you have to use a strategy like one of my examples above. If you don’t have a MISSING, consider the issue pieter raises about the file format.

      • #710051

        1. If i have a template that uses the Microsoft DAO 3.51 Object library in it, what are the minimum requirements needed for it to run on another PC that has Word 97 or Word 2000? I noticed that the template works correctly on “some” WOrd 2000 Pcs and not all. On the ones it does not work on it gives me runtime error 429 : ActiveX component can’t create object. thsi error message occurs at teh command where I am trying to “OpenDatabase”.

        2. If i want a template to work on both Word 97 and 2000 and uses DAo objects, is it ok to compile the template In Word 97 and it will work on 2000? Am i doing this the right way?

        Thanks…

        Thanks..

    • #709263

      DAO 3.6 is the version for Office 2000/2002. In Office 97, the correct version is 3.5 or 3.51.

      If you open the document/template in Word 97 and set a reference to the 3.5 or 3.51 library, the code should work there, and the reference will probably update itself when the document/template is opened in Word 2000. This only works when going to a higher version.

    • #709368

      As an alternative strategy, you could use “late binding” by declaring your various DAO objects as Object and then setting them using stuff like one of the following:

      Sub TryLateBinding1()
      Dim DBE As Object   ' Will bind to DAO.DBEngine at runtime
      On Error Resume Next
      ' Try to create object reference to DAO 3.6
      Set DBE = CreateObject("DAO.DBEngine.36")
      ' If it failed, and it's an ActiveX error, try 3.5
      If Err.Number > 0 Then
          If Err.Number = 429 Then
              Err.Clear
              Set DBE = CreateObject("DAO.DBEngine.35")
              If Err.Number > 0 Then GoTo skipInto
          Else
      skipInto:
              MsgBox "ERROR! " & Err.Number & vbCrLf & Err.Description
              Exit Sub
          End If
      End If
      ' Got back to default error handling
      On Error GoTo 0
      Stop
      Set DBE = Nothing
      End Sub
       
      Sub TryLateBinding2()
      Dim DBE As Object   ' Will bind to DAO.DBEngine at runtime
      Select Case Application.Version
          Case "8.0"            '97
              ' Try to create object reference to DAO 3.5
              Set DBE = CreateObject("DAO.DBEngine.35")
          Case "9.0", "10.0"    '2000-XP
              ' Try to create object reference to DAO 3.6
              Set DBE = CreateObject("DAO.DBEngine.36")
          Case Else
              MsgBox "Cannot detect Word version"
      End Select
      Stop
      Set DBE = Nothing
      End Sub

      The first uses an ugly error-fall-back method, the second makes certain assumptions about the version of DAO associated with a version of Word. You might need to mix and match various aspects of these examples if you go down this road.

    • #709369

      As an alternative strategy, you could use “late binding” by declaring your various DAO objects as Object and then setting them using stuff like one of the following:

      Sub TryLateBinding1()
      Dim DBE As Object   ' Will bind to DAO.DBEngine at runtime
      On Error Resume Next
      ' Try to create object reference to DAO 3.6
      Set DBE = CreateObject("DAO.DBEngine.36")
      ' If it failed, and it's an ActiveX error, try 3.5
      If Err.Number > 0 Then
          If Err.Number = 429 Then
              Err.Clear
              Set DBE = CreateObject("DAO.DBEngine.35")
              If Err.Number > 0 Then GoTo skipInto
          Else
      skipInto:
              MsgBox "ERROR! " & Err.Number & vbCrLf & Err.Description
              Exit Sub
          End If
      End If
      ' Got back to default error handling
      On Error GoTo 0
      Stop
      Set DBE = Nothing
      End Sub
       
      Sub TryLateBinding2()
      Dim DBE As Object   ' Will bind to DAO.DBEngine at runtime
      Select Case Application.Version
          Case "8.0"            '97
              ' Try to create object reference to DAO 3.5
              Set DBE = CreateObject("DAO.DBEngine.35")
          Case "9.0", "10.0"    '2000-XP
              ' Try to create object reference to DAO 3.6
              Set DBE = CreateObject("DAO.DBEngine.36")
          Case Else
              MsgBox "Cannot detect Word version"
      End Select
      Stop
      Set DBE = Nothing
      End Sub

      The first uses an ugly error-fall-back method, the second makes certain assumptions about the version of DAO associated with a version of Word. You might need to mix and match various aspects of these examples if you go down this road.

    • #709566

      also make sure your database is in access 97 format.

    • #709567

      also make sure your database is in access 97 format.

    Viewing 5 reply threads
    Reply To: Microsoft DAO 3.6 Object Library (word 97, word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: