Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    References - Word & Excel (Access XP)

    I have a query about the order of References to Word & Excel Object libraries from an Access database.

    My database generates some Excel files, and some Word reports. I have a reference to the
    Microsoft Word 11.0 Object Library and the
    Microsoft Excel 11.0 Object Library.

    When I run the Word reports, I have to reference the Microsoft Word 11.0 Object Library first.
    When I create the Excel files, I have to reference the Microsoft Excel 11.0 Object Library first.

    If I run the Excel files, with reference to the Microsoft Word 11.0 Object library first, then it won't work.
    Similarly, if I run the Word reports, with reference to the Microsoft Excel 11.0 library first, then it won't work.

    Is there a way to specify the reference orders so that it will always work?

    Thanks

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: References - Word & Excel (Access XP)

    Can you post the code you use to create one of them - say a Word report. It sounds to me (just guessing) that there is some code which is ambiguous.

    I regularly create both Word and Excel files from within Access, and the order of the References has never matter to me.
    Regards
    John



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

    Re: References - Word & Excel (Access XP)

    To expand on John's remark about ambiguous code: there are some objects that have the same name in the Word and Excel. Selection is an example.

    If you use Selection in your code without specifying what it belongs to, VBA will probably interpret it as an object in the first (topmost) of the two in References. so you should always qualify such all Word and Excel objects. For example, if your application objects are objWord and objExel, use objWord.Selection to refer to the selection in Word, and objExcel.Selection to refer to the selection in Excel.

Posting Permissions

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