Consulting

Results 1 to 7 of 7

Thread: Properties Instead of Methods

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Properties Instead of Methods

    Selection.EndKey Unit:=wdStory
    Selection.EndKey Unit:=wdLine

    are methods, rather than properties, which I am rather looking for. As such, they are instructions to go the end of line or end of document, rather than an information about where is the end of line or document. In fact, I would like to know whether or not my pointer is currently at the end of line or end of document. In this way, I will be able to stop the loop the pointer is engaged when it has reached the end of line or document. So if anyone knows, please reply !
    Thanks !
    That was the response I got to something I answered elsewhere. Can you help?
    ~Anne Troy

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    This is off the top of my head because I'm a bit busy with other things

    The end of the document is uniquely identified by being the end of the Range which is the document. So end of document is ..

    Selection.Document.range.end
    And the end of the Selection is simply ..

    Selection.End
    They are both numbers - if they are the same you're at the end of the document.

    Lines are slightly different - there is no Line Object but you can identify the end of the current line using the built-in bookmark ..

    selection.Bookmarks("\Line").end
    If the selection is collapsed (i.e. just an insertion point) all is well and you can compare it to the selection.end

    BUT .. if the selection spreads over multiple lines the "\line bokmark returns the first line of the selection so some extra messing around would be needed in that case
    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

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Can you repeat what it is you want to happen?

    You wrote know if the current location is at the end of a line, or the end of the document. What if neither applies. The current location is in the middle of the line?

    I am not sure what you want.

  4. #4
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Hi, guys.
    Thanks for your help.
    Might as well *out* with it...it's here:
    http://www.developerfusion.com/forums/topic-21762
    ~Anne Troy

  5. #5
    VBAX Regular Kelly's Avatar
    Joined
    Jun 2004
    Location
    Los Angeles, California
    Posts
    84

    A few more thoughts...

    I meant to reply to this a couple of days ago, and then I forgot.

    I had two ideas.

    1. There is a property called Selection.IPAtEndOfLine that returns "true" or "false." Selection.IPAtEndOfLine will be true ONLY when the selection point is collapsed to an insertion point(cursor), and the point is at the end of a line.

    2. My other thought was:

    Assuming the Selection point is collapsed, then the following:


    If Selection.Characters(1) = Chr(13) Then
    would test to see if you are at the end of a "paragraph" - in other words, if you are right at the "invisible" carriage return character.

    I suppose I could imagine good uses for either of these.

    However, I just noticed that Dreaboat "outed" the original thread...
    So now, I will take a look at:
    http://www.developerfusion.com/forums/topic-21762

    maybe after I get a firm grasp of their discussion I will have more to add

    -Kelly

  6. #6
    VBAX Regular Kelly's Avatar
    Joined
    Jun 2004
    Location
    Los Angeles, California
    Posts
    84
    Oh!

    I just visited the "mirror" thread at developerfusion, and it appears that "Claudealie" came up with a good solution.

    To get the current line number, the solution was:

    Selection.Range.Information(wdFirstCharacterLineNumber)

    That works great.

    However, I guess that is a different action than determining if you are at the end of the line.

    Since the original question was to find a 'property' that would be roughly equivalent to the "Selection.EndKey Unit:=wdLine" method, then I guess I stand by my earlier proposal of Selection.IPAtEndOfLine or testing for Chr(13)

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Nice, Kelly, I didn't know that.
    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

Posting Permissions

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