View Single Post
 
Old 10-18-2011, 11:54 AM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Windows 7 64bit Office 2010 32bit
Moderator
 
Join Date: Aug 2011
Posts: 4,036
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

Using Building Blocks or a template would be a lot easier.

The basic problem with the macro is that the selection changes as you run it, which is why the formatting won't get applied to the paragraphs where you want it.

If you insist on using a macro, you would have to do something like this instead:

Code:
 
Sub ApplyDirectFormattingToText()
Dim r As Range
Set r = Selection.Range
With r
.Collapse wdCollapseEnd
.InsertAfter "First paragraph" ' replace with your text!
.InsertParagraphAfter
.InsertAfter "Second paragraph"
.InsertParagraphAfter
.InsertAfter "Third paragraph"
.InsertParagraphAfter
.InsertAfter "Fourth paragraph"
.Font.Name = "Arial"
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Paragraphs(1).Range.Font.Size = 16
.Paragraphs(1).Range.Font.Bold = True
.Paragraphs(2).Range.Font.Size = 10
 
.Paragraphs(3).Range.Font.Size = 12
.Paragraphs(4).Range.Font.Size = 12
End With
End Sub
You could make the macro more effective by having it apply styles to text paragraphs instead.
__________________
Stefan Blom
Microsoft Word MVP

Microsoft 365 apps for business
Windows 11 Professional
Reply With Quote