Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2003
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting a Range in Word (2000)

    Hello,

    I want to be able to select a part of a document to copy to another document.
    To do that I set 2 bookmarks (oBook1, oBook2 one at the beginning, one at the end) braketing what I want to select.
    Then I create a Range object oRange.
    The idea being to do oRange.Select, then, Copy and Paste to the other doc.

    I get an error when I do oRange.Start = oBook.Start and oRange.End = oBook2.End
    It looks to me that the code above should work, but...

    My question: does anyone knows what is wrong and a better way to go ?

    Thanks

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

    Re: Selecting a Range in Word (2000)

    You say that you "create a Range object". Just declaring Dim oRange As Range does not create an object, you must assign a range to it.

    Dim oRange As Range
    Set oRange = ActiveDocument.Range(oBook1.Start, oBook2.End)
    oRange.Copy.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Selecting a Range in Word (2000)

    Are you aware you can use one bookmark instead of two? Despite the name 'bookmark' it really is more akin to a named range in Excel. If you select the entire range you wanted and choose Insert > Bookmark then the entire range will 'be' the bookmark.

    This will simplify your code and make the task easier to do.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    New Lounger
    Join Date
    Sep 2003
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting a Range in Word (2000)

    Thanks it works now...

  5. #5
    New Lounger
    Join Date
    Sep 2003
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting a Range in Word (2000)

    Thanks Andrew

    True, I though about it, but the selection I want will hold several 'not empty' Bookmarks, and I am afraid to get mixed up down the road...

Posting Permissions

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