Results 1 to 7 of 7
  1. #1
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Macro to Reapply Styles

    I sometimes get documents from other attorneys that use the standard heading styles, but yet the formatting is out of whack (e.g., margins are off, tabs are off, etc.). I can fix this by re-applying the style manually, but this is time consuming. I know about Ctrl+Q and Ctrl+Spacebar to remove formatting, but this doesn't help. I have a macro that re-sets styles to remove the "Jason" tabs problem (I realized that the Jason tabs issues is fixed in later versions of Word, I still get docs back from other attorneys where the tabs I set in the original doc are all out of whack). In any event, does anybody have a macro that scrolls through a document paragraph by paragraph and re-applies the current style to the paragraph?? If so, I sure would appreciate being able to try it!

    Thx.

    -Rich

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2006
    Location
    Maryland, USA
    Posts
    690
    Thanks
    17
    Thanked 66 Times in 56 Posts
    A macro may be just the thing, but have you considered reapplying your styles by temporarily turning on update styles from template? Or if you have created a style set for the template, reapplying the style set to update the styles in the document? If you have a lot of direct formatting to get rid of, you can select all instances of a style, click clear the direct formatting and then reapply the style.

    I'm not sure what you mean by "margins are off" because margins (a section property) can't be fixed in paragraph styles. I'm guessing that you mean indents, and if those indents are wrong on autonumbered paragraphs, the correction is best made in the numbering (instead of the style) or by reapplying the multilevel list style (with the cursor in the first level 1 numbered paragraph in the doc (usually a heading 1).


    Pam

  3. #3
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post
    I might have misspoken about the margins. I did mean indents/out-dents. In any event, while your suggestion is helpful in the right situation, the styles in the document are from someone else's template (or in the doc itself) rather than in my template because I received the doc from a third-party. So, I don't want to apply MY styles; I just want to reapply the document's styles. I did this manually for way too many paragraphs so I thought a macro would work. I can probably write a macro to scroll through each paragraph, but I'm not sure I know the code to check the current style and reapply it (although if no one has any suggestions, I'll try recording some code and modifying to see if I can get it to work). Thanks!

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Here's a simple version of code that will loop through every paragraph in the document, and reapply whatever style is applied, to each paragraph. It's been awhile since I've done this type of exercise, so there might be some gotchas, but it works OK in a test document here.
    Code:
    Sub ReapplyAllParaStyles()
       Dim aPara As Paragraph
       Dim sStyleName As String
       
       For Each aPara In ActiveDocument.Paragraphs
          sStyleName = aPara.Style
          aPara.Style = sStyleName
       Next 'aPara
    End Sub
    Gary

  5. The Following User Says Thank You to Gary Frieder For This Useful Post:

    rcbjr2 (2012-02-22)

  6. #5
    WS Lounge VIP
    Join Date
    Mar 2006
    Location
    Maryland, USA
    Posts
    690
    Thanks
    17
    Thanked 66 Times in 56 Posts
    Ah, that is a different situation. I hope Gary's macro works for you.

  7. #6
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post
    Thanks for the code, Gary. I appreciate it.

    -Rich

  8. #7
    New Lounger
    Join Date
    Sep 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Gary, it works wonderfully.

    Quote Originally Posted by Gary Frieder View Post
    Here's a simple version of code that will loop through every paragraph in the document, and reapply whatever style is applied, to each paragraph. It's been awhile since I've done this type of exercise, so there might be some gotchas, but it works OK in a test document here.
    Code:
    Sub ReapplyAllParaStyles()
       Dim aPara As Paragraph
       Dim sStyleName As String
       
       For Each aPara In ActiveDocument.Paragraphs
          sStyleName = aPara.Style
          aPara.Style = sStyleName
       Next 'aPara
    End Sub
    Gary

Posting Permissions

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