Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Macro for reformatting Word

Posted on 2014-12-10
Medium Priority
Last Modified: 2014-12-10
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?
Question by:normanwillis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 52

Accepted Solution

Rgonzo1971 earned 2000 total points
ID: 40491977

pls try

Sub Macro()

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

Open in new window


Author Closing Comment

ID: 40492230
Nailed it first try.

Author Comment

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.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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