Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Setting Ranges (VBA/Word/2000)

    Hello All,

    I was wondering what the difference is between:

    Set oRange = Activedocument.content

    and

    set oRange = Activedocument.Range

    I uses ranges all the time and I don't know why I should use one method over the other.

    Thank you,

  2. #2
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Ranges (VBA/Word/2000)

    Technically, Content is a property, and Range is a method, but both return the same Range object (pretty intuitive, isn't it?)

    As far as I know, all three of the following are equivalent:
    <pre>ActiveDocument.Range.Select
    ActiveDocument.Content.Select
    ActiveDocument.StoryRanges(wdMainTextStory).Select
    </pre>


    As they say in the Perl world, TMTOWTDI (There's More Than One Way To Do It).

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Setting Ranges (VBA/Word/2000)

    <code>ActiveDocument.Content</code> always is always the entire range of the main story.

    <code>ActiveDocument.Range</code> is a special case of <code>ActiveDocument.Range(Start:=x,End:=y)</code> and can return any range within the document.

    StuartR

  4. #4
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Ranges (VBA/Word/2000)

    Thanks for clarifying, Stuart, I should have said that the Range method uses the whole range by default.

    BTW, you can still use the Content property to get a sub-range -- you just have to walk back up the object tree:

    <pre>ActiveDocument.Content.Parent.Range(start:= x, end:=y)
    </pre>


    Not that I can think of any situation when you'd actually want to do that ...

Posting Permissions

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