Finding block of text with different formatting in Word document using Macros?

I wonder if something like this would suit.

I wonder if something like this would suit: Dim s As Range Dim wd As Range Dim BoldHead As Boolean Dim doc As Document Set doc = Word. Documents("Doc2. Doc") For Each s In doc.

Sentences If s. Words(1). Bold = True Then BoldHead = True For Each wd In s.

Words If Trim(wd) vbNullString _ And wd ". " _ And wd. Bold = False Then BoldHead = False End If Next If BoldHead Then Debug.

Print s End If End If Next Note that Word has a nasty enough habit of not counting the numbers, it sees them as automatic.

Ideally, a macro would be best for the users who will be doing the cleanup. – James Skemp Feb 17 '11 at 14:31 1 No, not at all, you could Set doc = ActiveDocument – Remou Feb 17 '11 at 14:57 Sorry for the late response (I try to enjoy my vacation days when I can :D). I tried this out this morning and it appears to do exactly as I need.

I want to test this against a larger document today, but right now it appears this is the solution. – James Skemp Feb 21 '11 at 17:50 I ended up tweaking it so that I could search only the first sentence in each paragraph, but this was exactly what I needed to finish up my issue. Thanks!

– James Skemp Feb 21 '11 at 21:02 @James Good. I am glad it worked out for you. – Remou Feb 21 '11 at 21:03.

Remou's answer is exactly what I needed, but since StackOverflow is a great resource, this is what I ended up tweaking it to for our particular case: In particular, the text is within the first sentence of a paragraph. Unfortunately this doesn't seem to catch all of our cases, but it grabs most of them, and gets the user most of the way there. (Some of the comments below were included on external resources I'd found, so whether they're actually necessary is questionable, but ... it works.) ' Do our bold heading replacements Dim s As Range, p As Paragraph Dim wd As Range Dim BoldHead As Boolean Dim doc As Document Set doc = ActiveDocument For Each p In doc.

Paragraphs Set s = p.Range. Sentences(1) If s. Words(1).

Bold = True And s. Words(1). Characters(1) = "(" Then BoldHead = True For Each wd In s.

Words If Trim(wd) vbNullString _ And wd ". " _ And wd. Bold = False Then BoldHead = False End If Next If BoldHead Then With s.

Find ' Clear all previously set formatting for Find dialog box. . ClearFormatting .

Text = "(\(0-9@\)) (?@). " ' Clear all previously set formatting for Replace dialog box..Replacement. ClearFormatting .Replacement.

Text = "\1 \2." .Replacement.Font. SmallCaps = True .Replacement.Font. Name = "Times New Roman" .Replacement.Font.

Bold = False ' The following parameters must be set as follows to find only text formatted for the specified font. . Forward = True .

Wrap = wdFindContinue . Format = True . MatchCase = False .

MatchWholeWord = False . MatchWildcards = True . MatchSoundsLike = False .

MatchAllWordForms = False . Execute Replace:=wdReplaceOne End With With s. Find ' Clear all previously set formatting for Find dialog box.. ClearFormatting .

Text = "(\(0-9@\)) " ' Clear all previously set formatting for Replace dialog box..Replacement. ClearFormatting .Replacement. Text = "\1" & vbTab .Replacement.Font.

SmallCaps = False .Replacement.Font. Name = "Arial" .Replacement.Font. Bold = True ' The following parameters must be set as follows to find only text formatted for the specified font.. Forward = True .

Wrap = wdFindContinue . Format = True . MatchCase = False .

MatchWholeWord = False . MatchWildcards = True . MatchSoundsLike = False .

MatchAllWordForms = False . Execute Replace:=wdReplaceOne End With End If End If Next.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions