Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 09-18-2014, 10:19 PM
macropod's Avatar
macropod macropod is offline Oh Please Lawd Halp me figure out how to make formatting these damnable documents a smaller job Windows 7 64bit Oh Please Lawd Halp me figure out how to make formatting these damnable documents a smaller job Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,514
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I've had a look at your onedrive document. Sadly, it doesn't make any use of Word's Styles. Everything is in Word's Normal Style, overridden with hard formatting so that nothing in your document seems to look like what the Normal Style says it should. That makes even a manual conversion much harder than it needs to be. It also makes the document harder to maintain and more prone to corruption. Even your table of contents, because the document doesn't make use of Styles, has to be manually prepared, whereas in a document using Styles it can be generated and updated quite easily.

Just to give you an idea of what's possible, copy & paste the document from the link in your first post into a new document, as unformatted text. Then run the following macro. For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
Code:
Sub ReformatStatuteText()
' Turn Off Screen Updating
Application.ScreenUpdating = False
Dim TrkStatus As Boolean      ' Track Changes flag
With ActiveDocument
  ' Store current Track Changes status, then switch off
  TrkStatus = .TrackRevisions
  .TrackRevisions = False
  With .Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    'Delete paragraphs containing just tabs
    .Text = "[^t]@^13"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    'Replace all double spaces with single spaces
    .Text = "[ ]{2,}"
    .Replacement.Text = " "
    .Execute Replace:=wdReplaceAll
    'Limit paragraph breaks and manual line breaks to one 'real' paragraph per set.
    .Text = "[^13^11]{1,}"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    'Delete 'Acts' paragraphs
    .Text = "^13Acts [0-9]{4}*^13"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    'ReFormat 'Title' paras
    .Format = True
    .Text = "TITLE ([0-9]{1,}. )(*^13)"
    .Replacement.Text = "Part \1- \2"
    .Replacement.Style = "Heading 1"
    .Execute Replace:=wdReplaceAll
    'ReFormat 'CHAPTER' paras
    .Text = "CHAPTER [0-9]{1,}. (*^13)"
    .Replacement.Text = "\1"
    .Replacement.Style = "Heading 2"
    .Execute Replace:=wdReplaceAll
    'ReFormat 'CHAPTER' paras
    .Format = False
    .Text = "(Art. [0-9.]{1,} [!.]@.) (*^13)"
    .Replacement.Text = "\1^p\2"
    .Execute Replace:=wdReplaceAll
    .Format = True
    .Text = "Art. [0-9.]{1,} [!.]@.^13"
    .Replacement.Text = "^&"
    .Replacement.Style = "Heading 3"
    .Execute Replace:=wdReplaceAll
  End With
  ' Restore original Track Changes status
  .TrackRevisions = TrkStatus
End With
' Restore Screen Updating
Application.ScreenUpdating = True
End Sub
The macro does some basic clean-up work, then applies Word's Heading 1, 2 & 3 Styles to the various headings. All this is done using Find/Replace sequences you could do manually via the Find/Replace dialogue. Granted, the results probably don't reflect what you want for the final output, but simply modifying the heading Styles to suit, including with the use of multi-level list numbering, can generate that output. Note how the macro doesn't do any direct formatting - it just calls the Styles for that. Change any of those Styles' definitions, even after running the macro, and all the corresponding headings will change.

To make full use of this approach, you really do need to learn to use Styles - and to use them consistently. The time taken to do so will very quickly pay for itself. Check out Charles' links.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
formatting, styles



Similar Threads
Thread Thread Starter Forum Replies Last Post
Caption Order: Figure 4 Figure 3 Figure 2 golfarchitect13 Word 5 05-07-2014 07:15 PM
Make a new Style available in legacy documents BlueClearSky Word 3 11-22-2013 03:12 PM
Combining Multiple Word Documents Heading/Figure Issues Word 2007 grantgibson45 Word 1 09-10-2012 11:00 PM
Oh Please Lawd Halp me figure out how to make formatting these damnable documents a smaller job How to make Quick Access Toolbar icons smaller in XP WaltR Word 1 04-09-2012 11:42 AM
Auto-updating smaller documents in a larger word file nmawells Word 0 05-27-2010 07:20 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:34 PM.


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