Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    53
    Thanks
    2
    Thanked 1 Time in 1 Post

    Setting References for Office Versions (2000/2002)

    I suspect this has been answered before, but I'm afraid I cannot find any relevant posts.

    In an application I have written Iusing Excel VBA) I am exporting to Word, and hance need to set a reference to the relevant Word Object Library. Because the application is required to work on both Office 2000 and Office 2002, I need to be able to dynamically detect which version (9 or 10) of the object library is required, and then set it when the application initialises.

    Is there a way to do this so that I avoid errors due to missing references, etc?

    Thanks.
    Geoffrey

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Setting References for Office Versions (2000/2002)

    Although it is possible to set references in code, it is tricky.

    One possibility is to create the final version on an Office 2000 machine. If it is run on an Office 2002 (XP) or Office 2003 machine, the references should update themselves automatically to the newer version (the reverse doesn't always work).

    Another possibility is to keep the reference while developing (so that you benefit from IntelliSense), then switch to late binding for the "production" version:
    - Change all declarations of Word objects to As Object, for example Dim objWord As Object instead of Dim objWord As Word.Application and Dim objPar As Object instead of Dim objPar As Word.Paragraph.
    - Replace all Word VBA constants with their value, for example replace wdSaveChanges with -1, and wdParagraph with 4, etc. You can use the Object Browser to look up these values.
    - Finally, remove the reference to the Microsoft Word n.0 Object Library.

    And of course, you shouldn't use any Word 2002 specific features.

  3. #3
    Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    53
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Setting References for Office Versions (2000/2002)

    Thanks Hans. The late binding approach is what I was after. Much appreciated.
    Geoffrey

  4. #4
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    268
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Setting References for Office Versions (2000/2002)

    You could also try this article

Posting Permissions

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