Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    selection text - using ExtendSelection (Word 2002 XP SR3)

    Im performing a search for a paragraph of text.
    I search for the first line of the text and add a "start" bookmark.
    I then search for the last line of the text and add an "end" bookmark.
    my code then goes to the start bookmark and extends selection to the end bookmark.
    deletes the selection and inserts new text.
    i repeat and do another search for different text.

    when I step thru the code this appears to work. However when I run the code i get errors.

    I have a feeling its to do with the "ExtendSelection" I've used. As in Word if ExtendMode is left on, the selection and mouse can go a bit spac.

    heres my code...

    If ActiveDocument.Bookmarks.Exists("bkStart") = True Then
    ActiveDocument.Bookmarks("bkStart").Select
    With Selection
    .ExtendMode = True
    .GoTo What:=wdGoToBookmark, Name:="bkEnd"
    End With
    Selection.Delete
    End If

    Do I need to turn off the ExtendSelection command before I perform each search?
    Or is there a better way to select a couple of paragraphs of text?

    diana

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

    Re: selection text - using ExtendSelection (Word 2002 XP SR3)

    You can delete the range without selecting anything:

    If ActiveDocument.Bookmarks.Exists("bkStart") = True Then
    ActiveDocument.Range(ActiveDocument.Bookmarks("bkS tart").Start, _
    ActiveDocument.Bookmarks("bkEnd").End).Delete
    End If

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection text - using ExtendSelection (Word 2002 XP SR3)

    Many thanks again Hans

    diana

Posting Permissions

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