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. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,944
    Thanks
    0
    Thanked 203 Times in 184 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]

  3. #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

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,944
    Thanks
    0
    Thanked 203 Times in 184 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]

  5. #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

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,944
    Thanks
    0
    Thanked 203 Times in 184 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]

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

    violet (2012-01-31)

  8. #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
  •