![]() |
|
#1
|
|||
|
|||
|
I discovered the following code (from a March 31, 2015 thread) while exploring this forum, and it has been very helpful to say the least. I was wondering, though, how to modify it to include multiple styles (if that is even possible). Currently, I have one macro calling on another, calling on another, and on and on.
Thank you in advance for considering my request for help. Code:
Sub MarkBodyText()
' Author: A. Lockton (a/k/a Guessed) via msofficeforums.com
' Date: April 2015
' Notes: Adds "(XX)" at start of every para styled as specified
Application.ScreenUpdating = False
WithActiveDocument.Content.Find
.ClearFormatting
.Style = "Body Text" 'Changestyle, here
DoWhile .Execute(Forward:=True, Format:=True) = True
With .Parent
If Left(.Text, 1) = vbCr Or Left(.Text, 1) = " " Or Left(.Text, 1) = chr(12) Then
'do nothing
Else
.InsertBefore "(XX) "
End If
If .End = ActiveDocument.Content.End Then
Exit Do
Else
.Move Unit:=wdParagraph, Count:=1
End If
End With
Loop
EndWith
Application.ScreenUpdating = True
End Sub
Last edited by macropod; 04-15-2021 at 02:53 PM. Reason: Cleaned up post formatting and added code tags |
| Tags |
| add text, all paragraphs, search styles |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word macro to insert text at the beginning of paragraph but skip tables
|
ashalles135 | Word VBA | 5 | 09-26-2018 09:49 AM |
word macro To insert text at the beginning and at end of paragraph
|
ArieH | Word VBA | 20 | 09-10-2017 04:23 PM |
Macro to Insert text into the beginning on specific paragraphs unless the paragraph is blank
|
caboy | Word VBA | 2 | 04-01-2015 07:00 AM |
| How to find all numbers that start with a paragraph? | csongi12xme | Word | 7 | 07-22-2014 07:55 AM |
| Justify Paragraph Start position with VBA | jeff_kaufman | Word VBA | 2 | 11-09-2013 12:15 PM |