Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Determine end of selection (Word 97/XP)

    I am using Selection.InsertAfter command to insert text after the current selection. Sometimes the selection is in the middle of a paragraph and sometimes at the end of the paragraph. What I would like to do is to move 1 character back of the selection is at the end of the paragraph.

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

    Re: Determine end of selection (Word 97/XP)

    You could try something like

    if Selection.End = Selection.Paragraphs(Selection.Paragraphs.Count).R ange.End then Selection.MoveEnd unit:=wdCharacter, Count:=-1

    This will move the end of the selection back one if the Paragraph mark at the end of a paragraph is the final thing selected. If you want to be one character earlier then you may need to move an additional character back, and / or to compare with
    Selection.Paragraphs(selection.Paragraphs.Count).r ange.End -1.

    You possibly also need to check that Selection.Type is something suitable (if a graphic is selected then this code won't actually give errors, but it won't do anything useful either)

    StuartR

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Determine end of selection (Word 97/XP)

    Test whether you are at end of paragrah, then use Collapse method.

  4. #4
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Determine end of selection (Word 97/XP)

    Thanks so much Stuart!!!

Posting Permissions

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