Finding Headings from text copied from web pages

P

Paul Martin

When I regularly copy text from web pages into Word, I want to be able
to detect the headings and convert them to Title Case.

Most of the text I copy pastes in Word at 12pt fonts while the
headings paste at 24pt (but no Heading style).

Can anyone suggest how I might loop through the document to detect
these headings?

Thanks in advance

Paul Martin
Melbourne, Australia
 
G

Graham Mayor

The following macro will convert all 24 point text to TitleCase

Sub ReplaceExample()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Font.Size = "24" 'find 24 point text
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
While .Execute = True
With Selection.Range 'the found text
.Case = wdTitleWord 'set title case
'do whatever else you want to the found text e.g.
'.Style = "Heading 1"
'.Font.Size = "18"
End With
Wend
End With
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top