Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Deleting text with sequential numbers: MS Word 2003

    Hi all,

    I have some documents that are produced as a result of exporting content from eLearning modules. I need to be able to delete certain content such as repeated wording, graphics etc, most of which I can already do, however, am not sure how to tackle the following:
    • The documents contain several instances of the following text:
    "slide x - slide x"
    where "x" is a sequential number starting at 1 and incrementing to any point.
    Essentially all I need to be able to do is a find and replace (with nothing), but I'm stuck on the incremental part.
    Hope someone can help.

    Thanks,

    V

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,869
    Thanks
    0
    Thanked 180 Times in 165 Posts
    Hi violet,

    Try a wildcard Find/Replace, where:
    Find = slide [0-9]{1,} - slide [0-9]{1,}
    Replace = nothing
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Paul, thanks for the prompt reply. I'm sorry to say I'm lost, however :s

    Could you elaborate on the code I'd need please?

    Thanks, V

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,869
    Thanks
    0
    Thanked 180 Times in 165 Posts
    Hi Violet,

    For the solution I posted you don't need any code. Simply press Ctrl-H to open the Find/Replace dialogue, input the Find string, check the 'use wildcards' option (you may need to click 'More' to see this) and click 'Replace All'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry, that's my fault for not being more specific - I'm creating a toolbar for a user so she can tidy the various output documents herself hence mentioning code.

    I did try the find and replace initially to see if the Find string produced the results I needed in the document, but it didn't work (see below).

    Thanks, V

    find_replace.GIF

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,869
    Thanks
    0
    Thanked 180 Times in 165 Posts
    Hi Violet,

    Nothing was found because, unlike the specifications you gave earlier (slide x - slide x), your document has 'Slide x - Slide x'. to cope with either rendition, you could make the Find expression:
    [Ss]lide [0-9]{1,} - [Ss]lide [0-9]{1,}

    The code equivalent is:
    Code:
    With ActiveDocument.Content.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "[Ss]lide [0-9]{1,} - [Ss]lide [0-9]{1,}"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchKashida = False
      .MatchDiacritics = False
      .MatchAlefHamza = False
      .MatchControl = False
      .MatchAllWordForms = False
      .MatchSoundsLike = False
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. The Following User Says Thank You to macropod For This Useful Post:

    violet (2012-01-31)

  9. #7
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That's it! Ideal. Thanks very much, V.

Posting Permissions

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