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

    selection text leaves last char behind? (Word 2002 XP SR3)

    Very long fragment of code moved to text fule by HansV

    I've code which does the following:
    search text, if text is found add a bookmark
    search for end text, if text found add an end bookmark
    delete bookmark text and insert an autotext entry.

    One user is getting an error. I've steped thru the code and I discovered the search end string, leaves the last character behind (not deleted).

    This error occurs intermittanlty.

    The only other person that got the same issue was a previous user that sat in the exact desk . The previous user has moved to another desk location and has taken everything with them ie pc, mouse keyboard etc. They no longer experience the error.

    I've asked if they maybe using a shortcut, or a press a keyboard button at the time the error occurs and theyre not.

    I'm stumped as to why this may occur. <gosh>

    any ideas?

    diana
    Attached Files Attached Files

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

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    If you make bookmarks visible (tick Bookmarks in the View tab of Tools | Options) you should be able to see where the bkStart and bkEnd bookmarks are set. Is that different on the problem PC?

    BTW, you don't need to set bookmarks in order to delete a range. You can store the start or end of a range or selection in variables of type Long, then use something like Range(lngStartPos, lngEndPos).Delete

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    I don't know if it will help with this problem, but have you considered using Regular Expressions to locate the target text block?

    http://www.2150.com/regexfilter/Documentation/regex.doc
    Add power to Word searches with regular expressions - Help and How ...
    Putting regular expressions to work in Word - Help and How-to ...

    all look like good references.

    Alan

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

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    Regular expressions may be overkill for this situation - Word has built-in support for searching using wildcards, with added bells and whistles. It doesn't provide the full power of regular expression search, but it is sufficient for most situations.

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    Sure, but what kind of "standard wildcard" expression would you use to search out and then select
    [start string]<some random text block>[end string]?

    Alan

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

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    I'd use <code>[start string]*[end string]</code>.
    And tick the check box "Use wildcards", of course.
    Attached Images Attached Images
    • File Type: png x.png (13.7 KB, 0 views)

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    Too easy! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    Alan

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

    Re: selection text leaves last char behind? (Word 2002 XP SR3)

    thank you Hans & Alan

    ill take a look & let u know how i go

    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
  •