Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-27-2023, 10:36 AM
RobiNew RobiNew is offline Stable change to structure level 'Body Text' Windows 10 Stable change to structure level 'Body Text' Office 2016
Competent Performer
Stable change to structure level 'Body Text'
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default 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

Reply With Quote
  #2  
Old 11-27-2023, 03:19 PM
Guessed's Avatar
Guessed Guessed is offline Stable change to structure level 'Body Text' Windows 10 Stable change to structure level 'Body Text' Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 11-28-2023, 05:17 AM
Italophile Italophile is offline Stable change to structure level 'Body Text' Windows 11 Stable change to structure level 'Body Text' Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

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.
Reply With Quote
  #4  
Old 11-28-2023, 02:35 PM
Guessed's Avatar
Guessed Guessed is offline Stable change to structure level 'Body Text' Windows 10 Stable change to structure level 'Body Text' Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #5  
Old 11-28-2023, 03:00 PM
Italophile Italophile is offline Stable change to structure level 'Body Text' Windows 11 Stable change to structure level 'Body Text' Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by Guessed View Post
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.
See http://www.blacksbergassociatesllc.c...aws-of-styles/

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.
Reply With Quote
  #6  
Old 11-28-2023, 06:03 PM
Guessed's Avatar
Guessed Guessed is offline Stable change to structure level 'Body Text' Windows 10 Stable change to structure level 'Body Text' Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #7  
Old 11-29-2023, 01:13 AM
RobiNew RobiNew is offline Stable change to structure level 'Body Text' Windows 10 Stable change to structure level 'Body Text' Office 2016
Competent Performer
Stable change to structure level 'Body Text'
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Thank you, Guessed, for your very instructive comments on my tentative code. Thanks to them I have solved now.
Reply With Quote
Reply



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
Stable change to structure level 'Body Text' 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

Other Forums: Access Forums

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


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