#1
|
|||
|
|||
Stable change to structure level 'Body Text'
I want to reduce the structure level to 'Body Text'. I'm using the code here below to 1. change all styles to 'Normal'; 2. change structure level to 'Body Text'. The code works properly (even without part 1), but when the doc is further elaborated the original level reappears (Level 1). Is there a more reliable code to obtain a stable change of structure level? Thanks!
Code:
Sub BodyText() '1. All paragraphs with Normal style On Error Resume Next Set MyStyle = ActiveDocument.Styles.Add(Name:="Normal", _ Type:=wdStyleTypeParagraph) Dim Para As Paragraph Dim fnt As Font Dim pfmt As ParagraphFormat For Each Para In ActiveDocument.Paragraphs With Para If .Style <> ActiveDocument.Styles("Normal") Then Set fnt = .Style.Font Set pfmt = .Style.ParagraphFormat .Style = ActiveDocument.Styles("Normal") .Range.Font = fnt .Range.ParagraphFormat = pfmt End If End With Next '2. Structure level to "Body text" Dim myRange As Range For Each Paragraph In ActiveDocument.Paragraphs NrPar = NrPar + 1 Set myRange = ActiveDocument.Paragraphs(NrPar).Range myRange.Style = ActiveDocument.Styles(wdStyleNormal) Next Paragraph End Sub |
#2
|
||||
|
||||
Firstly - why? What is the point of removing style information and applying the style formatting as local formats instead? In this macro you will lose all existing local formatting which it appears you are quite attached to for some reason.
You say you want to change 'structure level' - do you mean you want to change the outline level of the paragraphs but retain the formatting? What is the point of the undeclared MyStyle variable? It doesn't get used and is trying to re-create a built-in style that already exists in English versions of Word. With the second macro, how is it different to just applying Normal to the entire contents of the document? And finally, there are two different built-in styles called 'Normal' and 'Body Text'. The styles are not the same thing so be careful with your terminology.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
In a properly formatted document the "Normal" style would only be used when inserting tables. It is vital to the correct working of table styles that "Normal" is identical to the document default.
Text in the body of the document should be formatted in "Body Text" style, 'cos that's what it's for. |
#4
|
||||
|
||||
Italophile
I would happily debate you on the "Normal only in tables" stance. All my templates are based around Normal as the primary style for body text. Yes, I know that 'Body Text' is a built-in style that is there for that purpose but that doesn't necessarily make it the style to use. The main reason I prefer to use Normal as my goto style is that 90% of the content created by OTHER PEOPLE is already using Normal so there is far less re-styling required when pasting in text from other sources. If Microsoft's default templates used Body Text out of the box then Normal would never have gotten the dominant position that makes it so pervasive.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Quote:
The vast majority of Word users don’t have a clue how to use it correctly, but that doesn’t mean the rest should just give up and join them. Far better to attempt to educate them and encourage them to use it properly. |
#6
|
||||
|
||||
An interesting take but I'm not convinced based on the strength of that article. There are several places where those laws are based on good principles but IMHO misleading. Eg never any place for Automatically Update styles (TOC styles?); never use format painter (even to apply a paragraph style?)
Their reasoning for avoiding Normal style is completely without basis. A definition for 'Normal' is conforming to a standard; usual, typical, or expected so it sounds like an apt style name for the most commonly used paragraph formatting. Body Text works too but it doesn't have the sole claim for this purpose. Again, I go back to the default templates from Microsoft - since they chose Normal, the preponderance of content you will encounter is going to be based on Normal. Plus just about every style is based on Normal in those templates so the beauty (and horror) of cascading style attributes is already aligned with Normal as your starting style. At least you gave a more meaningful reason related to table styles (which didn't exist when that guy wrote his blog article).
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#7
|
|||
|
|||
Thank you, Guessed, for your very instructive comments on my tentative code. Thanks to them I have solved now.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to conditionally hide text by language/structure? | tyxanu | Word VBA | 10 | 08-31-2020 11:14 PM |
Normal, Body Text or Body Text Indent? | Riddles | Word | 3 | 04-08-2017 05:06 PM |
Numbering Body text with prefixed Heading Level | kmeloy | Word | 5 | 10-04-2012 01:04 AM |
Complicated question about multi-level list with body text | rhino79 | Word | 5 | 08-26-2012 05:17 AM |
Outline level to Body Text | dariober | Word | 0 | 08-23-2010 02:54 AM |