Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-18-2011, 11:54 AM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Macro - Microsoft Word 2010 Windows 7 64bit Macro - Microsoft Word 2010 Office 2010 32bit
Moderator
 
Join Date: Aug 2011
Posts: 4,049
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - Microsoft Word 2010 Microsoft Word 2010 - Aligning table horizontally SWEngineer Word Tables 4 07-20-2011 01:32 AM
Macro - Microsoft Word 2010 Run a Macro in Word 2010 Joyce301 Word VBA 3 04-29-2011 03:27 PM
Make text permanent in Microsoft Word 2010, how? shaunzo101 Word 0 09-21-2010 08:27 PM
Please help with a macro in Microsoft Word 2007 AKMMS Word VBA 0 06-23-2010 02:16 PM
Word 2003 macro to Word 2007 to 2010 to... maruapo Word VBA 0 06-04-2010 03:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft