Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Style for the following paragraph (MS Word 2003, SP2)

    Hello,

    I am trying to create a unique macro that will:

    1. Loop through a folder full of word documents.
    2. Find the word "WARNING" (all caps) and the associated style for "WARNING" which is "WCN_Head".
    3. Delete the word "WARNING" and the associated style for "WARNING" which once again is "WCN_Head".
    4. Next, look for the "Style for the following paragraph:" - which is the NEXT STYLE under (or following) "WCN_Head". That style is called: "WCN_Text".
    5. Rename the "WCN_Text" style to: "Warning" style.
    6. Repeat until done.

    Does anyone know if it is possible to capture this process in a Macro? Please see attached screen shot. WCN stands for Warning, Caution and Note. I will repeat
    this process for Caution and Note - if I can get it to work for Warning.

    Thanks in advance for your assistance.

    Regards,

    -J
    Attached Images Attached Images

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

    Re: Style for the following paragraph (MS Word 2003, SP2)

    Try this (you know the routine by now):

    Sub ReplaceInDoc(doc As Document)
    Dim rng As Range
    Set rng = doc.Content
    With rng.Find
    .ClearFormatting
    .Text = "WARNING"
    .Style = "WCN_Head"
    .Replacement.ClearFormatting
    .Replacement.Text = ""
    If .Execute Then
    rng.Delete
    End If
    End With
    doc.Styles("WCN_Head").Delete
    doc.Styles("WCN_Text").NameLocal = "Warning"
    End Sub

Posting Permissions

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