Solved

Macro for reformatting Word

Posted on 2014-12-10
3
187 Views
Last Modified: 2014-12-10
Hello.
Is it possible to make a macro that will take 250-300 lines of text,
place a line break (Enter) between each line,
and then identify the line break as Heading 1, and the paragraph as Heading 2?
0
Comment
Question by:normanwillis
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40491977
Hi,

pls try

Sub Macro()
'

    Selection.WholeStory
    Selection.Style = ActiveDocument.Styles("Heading 2")
    For Idx = ActiveDocument.Paragraphs.Count To 1 Step -1
        ActiveDocument.Paragraphs(Idx).Range.Select
        Selection.HomeKey Unit:=wdLine
        Selection.TypeParagraph
        Selection.MoveUp Unit:=wdLine, Count:=1
        Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.Style = ActiveDocument.Styles("Heading 1")
    Next
    
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:normanwillis
ID: 40492230
Nailed it first try.
0
 

Author Comment

by:normanwillis
ID: 40492355
On the full document (1500 pages) it hung up. But it was fun to watch it operate on the shorter document (13 pages). It ran from back to front.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now