Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 200
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
 



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 12:06 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