Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Selecting text between 2 markers (WinXP OXP)

    I am wanting to use a macro to select and replace text between 2 markers depending on the input from a user. Currently I use Autotext entries to replace highlighted text but, because of changed requirements, this has become unusable. My thoughts were to highlight the text between bookmarks and replace using Autotext but I can't figure out how to do this.

    Can anyone help?

    Cheers
    cheers

    Phil Carter

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selecting text between 2 markers (WinXP OXP)

    Hi Phil:
    I can't help with the VBA part, but do you have control over the two markers. It's easy to use Find/Replace for:
    Using wildcards
    Find: M1*M2
    Replace: Whatever

    Can you adapt this technique for your task?

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Selecting text between 2 markers (WinXP OXP)

    Phil

    Thanks for that.

    After having a good look at what you suggested I don't think I can use it.

    Cheers
    cheers

    Phil Carter

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Selecting text between 2 markers (WinXP OXP)

    If you search for between two bookmarks you will find some links... after a couple clicks, I suggest this one and <post#=271050>post 271050</post#>. (I was lazy and only looked at my own posts, but there are plenty of others.)

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Selecting text between 2 markers (WinXP OXP)

    Jefferson

    Thanks again for all your help on this one.

    I couldn't get this to work from the posts you suggested. However, I did get it to work by putting all the required text, 3 versions within the the bookmark and saving them as autotext, selecting the bookmark, deleting the bookmark and inserting the new text as autotext entries. The autotext entries have embedded bookmarks that serve to allow the macro to be rerun if required.

    Not particularly elegant but works just fine.

    Cheers
    cheers

    Phil Carter

Posting Permissions

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