Consulting

Results 1 to 12 of 12

Thread: Selecting Word reference library

  1. #1
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location

    Selecting Word reference library

    Can vba code be used to find out if a reference to the Word library has been made and if it has not been made then select the reference? I would imagine that a certain error production would indicate a missing reference but I'm looking for a more direct approach. Also the problem of Word libraries having different numbers with different XL versions seems to make this difficult. I'm looking for suggestions other than late binding. if you have any, I sure would appreciate any assistance. Dave

  2. #2

  3. #3
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Dave -

    What's the earliest version of Office your users will be using? As much as it may hurt to go backwards, you must develop in that version on a computer that has no later versions installed on it, if you refuse to late bind. Set a reference to the Word library on that computer. If the Excel program is opened in the same version you're using, you're fine. If it's opened in a later version, the reference is automatically changed to the version you've opened on.

    If the file is developed in an earlier version, opened in a later version, then reopened in the earlier version, your references will break. This situation calls for late binding.

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______

  4. #4
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Jake and Jon it seems there is a juxtaposition between your posts. There seems to be hope and then there's reality. Well you know that this question is related to that post at that other site, late binding seems to be out. By the way, that code needs a bit of adjustment for group selections across pages. Jake thanks for those links. I'll hope and mess around with some code. Jon your right... all I'm going to do is crash my computer. The utility of this routine for me causes some niaeve optimism. I'll post if I come close. The help with this is truly appreciated. I'm open to any suggestions. Dave

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    What exactly is the problem with using Late Binding in this case?

  6. #6
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Here's a link http://www.mrexcel.com/board2/viewto...6269&highlight=
    Problem is the code here doesn't work unless a reference is set to the Word library. It's the expand paragraph line which errors out without the reference. I'm guessing that in this case, being that each line is a paragraph, I don't actually have to expand the paragraph, I only have to select the found line and perhaps avoid the reference. If that fails, back to trying to crash the puter. Thanks. Dave

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    I've just scanned the other threads here and there and the main problem appears to be solved. I don't, however, see any reason not to use late binding - early binding is required in order to use the wdParagraph constant, but hard coding its value of 4 instead would allow late binding.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Thanks Tony. I've updated the post at the previous link but I still haven't figured out how to get rid of the reference. It seems I just need to set a range to the paragraph with the found selection to avoid using the expand code. Doesn't seem to want to work for me yet. I'm not sure if I follow your suggestion? Dave

  9. #9
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Part of Early Binding is the use of descriptive constant names, such as wdParagraph, which are part of the object model, and represent numeric, difficult to remember values, such as 4.

    When you convert from Early to Late Binding, you must convert all he named constants into their numerical equivalents. You can find their equivalents in the Object Browser, or simply by asking in the Immediate Window:

    ?wdParagraph
    4

    I don't know if this is what you were asking, but it sounded as though you were unsure of Tony's suggestion. I haven't read your code; unless I print it out and scribble all over it with a pencil, trying to read large blocks code gives me a headache!

    - Jon

  10. #10
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    That's the first *real* tip I've seen on early -vs- late, Jon. Perhaps THAT (early -vs- late) is an article you could write (and we'd LOVE to have) in our articles section?
    ~Anne Troy

  11. #11
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    I have a small page on my web site:

    http://peltiertech.com/Excel/EarlyLateBinding.html

    I'm usually pretty retentive about listing them in my posts, but this time it slipped my attention.

    Do you mind rehashed examples among your articles? I could probably add a quick list of pros and cons to help users decide which to use, as well as the description of its behavior across different Office versions.

    - Jon

  12. #12
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    This has been a great learning adventure. I'm looking forward to reading the article. Apologies for the code eye strain. I'll post a solved to this thread. However, if anyone has any other relevent information, I would like to encourage them to post. The links and threads have been very informative(if you ignore my eyesore). Many thanks! Dave

Posting Permissions

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