Hi Christoph,
Quote:
> Thanks for that, this is great, I did know it was not going to be so easy,
> but the stuff with the GUID would not have been too easy to figure out.
So,
> how can I find out what number it is?
You mean the arguments for the AddFromGuid method? You can get these
properties: Guid, Major and Minor by running the last procedure in my
previous post when you've set the reference.
Quote:
> Now, what happens if there is a new version of DAO, i.e. DAO 3.7? Is that
> not going to make things even more confusing?
Yep .. then you have to modify it. But apart from setting the references
manually there's no other way to do it I'm afraid.
Hope this helps,
regards,
Astrid
So that all can benefit from the discussion,
please post all followups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/
For direct access to all Microsoft newsgroups:
Quote:
> > Hi Christoph,
> > Built your template with the reference you need on your system. When
> you're
> > going to distribute it, delete the reference and add a AutoOpen and
> AutoNew
> > macro that sets the reference for you:
> > ----------------------------------------
> > Sub AutoOpen()
> > On Error GoTo ErrHandlerAutoOpen
> > 'Ref to DAO 3.6
> > With Application.VBE.ActiveVBProject.References
> > .AddFromGuid "{00025E01-0000-0000-C000-000000000046}", 5, 0
> > End With
> > Exit Sub
> > DAO351:
> > 'Ref to DAO 3.51
> > With Application.VBE.ActiveVBProject.References
> > .AddFromGuid "{00025E01-0000-0000-C000-000000000046}", 4, 0
> > End With
> > Exit Sub
> > ErrHandlerAutoOpen:
> > Select Case Err
> > Case 48
> > 'Error in loading DLL
> > 'Try again with DAO 3.51
> > GoTo DAO351
> > Case Else
> > 'ErrHandler if neither DAO 3.51 or DAO 3.6 installed
> > End Select
> > End Sub
> > ----------------------------------------
> > To find out which numbers you need, just loop through all the references
> > when the correct DLL is set in Tools - References:
> > ----------------------------------------------------------------------
> > Dim oReference As Reference
> > For Each oReference In VBE.ActiveVBProject.References
> > If InStr(1, oReference.Name, "DAO", vbTextCompare) > 0 Then
> > Debug.Print oReference.Name
> > Debug.Print oReference.GUID
> > Debug.Print oReference.Major
> > Debug.Print oReference.Minor
> > End If
> > Next
> > Set oReference = Nothing
> > ----------------------------------------------------------------------
> > You'll need a reference to the Microsoft Visual Basic for Applications
> > Extensibilty Library to run this last procedure.
> > Hope this helps,
> > regards,
> > Astrid
> > So that all can benefit from the discussion,
> > please post all followups to the newsgroup.
> > Visit the MVP Word FAQ site at http://www.mvps.org/word/
> > For direct access to all Microsoft newsgroups:
> > > Hi there,
> > > I have word linking to an Access database via dao. I have added a
> > reference
> > > to the dao 3.5 model in my original template. this all works fine.
Now,
> on
> > > some of our machines, there is no dao 3.5 but a version of 3.6 because
> > > various apps have been installed that must have upgraded the dao
> version.
> > On
> > > those machines, my db connection fails. I have to manually change the
> > > reference on those machines which is very tedious. Is there a way of
> > cheking
> > > the reference or making this process automatic?
> > > Cheers Christoph