Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2022, 06:19 AM
Shelley Lou Shelley Lou is offline VBA Change to correct Heading style Windows 10 VBA Change to correct Heading style Office 2016
Expert
VBA Change to correct Heading style
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Change to correct Heading style

Hi Macropod, many thanks for your reply - I found out why it was creating a bug for the style - I had not created a new Schedule Level 8 style which I've now done and the code is working. I have noticed though that in the Define new Multilevel List dialog box all the styles are set to Aligned at: 0" but in the Style Pane they show the correct indent for each style - do I need to add something to the code for the Define new Multilevel List Aligned at: to update also?



Apologies for missing the .Font.Bold = False line which I've now added to the Schedule Level codes but this did not work in my Heading code, it removed the bold from the actual heading e.g. 1. Definitions - the number should not be bold but Definitions should be bold but .Font.Bold = Choose(i, 0, 0, 0, 0, 0, 0, 0) seems to work correctly.

Image.PNG
Reply With Quote
  #2  
Old 07-17-2022, 04:17 PM
macropod's Avatar
macropod macropod is offline VBA Change to correct Heading style Windows 10 VBA Change to correct Heading style Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
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

Quote:
Originally Posted by Shelley Lou View Post
I have noticed though that in the Define new Multilevel List dialog box all the styles are set to Aligned at: 0" but in the Style Pane they show the correct indent for each style - do I need to add something to the code for the Define new Multilevel List Aligned at: to update also?
I believe that's just how the Define new Multilevel List dialog box works.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-18-2022, 06:05 AM
Shelley Lou Shelley Lou is offline VBA Change to correct Heading style Windows 10 VBA Change to correct Heading style Office 2016
Expert
VBA Change to correct Heading style
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Change to correct Heading style

Hi Macropod, so I have figured out the issue with the Define new Multilevel List, I just needed to update the code which now updates the dialog box correctly.

Code:
.NumberPosition = InchesToPoints(Choose(i, 0, 0, 0.5, 1, 1.5, 2, 2.5))
    .TextPosition = InchesToPoints(Choose(i, 0.5, 0.5, 1, 1.5, 2, 2.5, 3))
You mentioned in a previous post why do I use two Heading 2 levels, one is set up to be plain text and the second one (Heading 2(Title) is when Heading 2 is a bold title within the same document. Heading 2(Title) is set up as style based on Heading 2 but when running one of my applymultilevel codes Heading 2(Title) does not update and therefore the numbering doesn't follow in sequence. Does VBA class this as another style even though its based on Heading 2?

Capture.PNG

Code:
Sub ApplyMultiLevelHeadingNumbers_B()
    'Run if Heading 4 is numbered (a)
Application.ScreenUpdating = False
Dim LT As ListTemplate, i As Long, n As Long, iLvl As Long
Call DPU_RemoveFirstLineIndents
Set LT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
For i = 1 To 6
With LT.ListLevels(i)
    .NumberFormat = Choose(i, "%1.", "%1.%2", "%1.%2.%3", "(%4)", "(%5)", "(%6)", "(%7)")
    .TrailingCharacter = wdTrailingTab
    .NumberStyle = Choose(i, wdListNumberStyleArabic, wdListNumberStyleArabic, _
      wdListNumberStyleArabic, wdListNumberStyleLowercaseLetter, wdListNumberStyleLowercaseRoman, _
      wdListNumberStyleUppercaseLetter, wdListNumberStyleArabic)
    .NumberPosition = InchesToPoints(Choose(i, 0, 0, 0.5, 1, 1.5, 2, 2.5))
    .TextPosition = InchesToPoints(Choose(i, 0.5, 0.5, 1, 1.5, 2, 2.5, 3))
    .Font.Bold = Choose(i, 0, 0, 0, 0, 0, 0, 0) 'Remove bold from heading numbers
    .Alignment = wdListLevelAlignLeft
    .ResetOnHigher = True
    .StartAt = 1
    .LinkedStyle = "Heading " & i
  End With
  With ActiveDocument.Styles("Heading " & i)
   Select Case i
      Case 1, 2
         .ParagraphFormat.LeftIndent = InchesToPoints(0.5)
      Case Else
      .ParagraphFormat.LeftIndent = InchesToPoints((i - 1) * 0.5)
    End Select
    .ParagraphFormat.FirstLineIndent = InchesToPoints(-0.5)
    .ParagraphFormat.Alignment = wdAlignParagraphJustify
    .Font.Name = "Arial"
    .Font.Italic = False
    .Font.ColorIndex = wdAuto
    .Font.Size = 10
  End With
Next
Application.ScreenUpdating = True
'Call ApplyHeadingStyles_IfManual
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Change to correct Heading style Word 2007: Unable to change character style, when using a linked Char/Para style format Last Chance Word 3 06-09-2021 12:52 PM
Using numbered list style, how to indent text immediately following heading to match heading indent? SpechtacularDave Word 3 09-25-2019 01:22 PM
Heading not following the correct numbering jongleur Word 2 05-16-2017 10:52 AM
VBA Change to correct Heading style Tab character causes style change to Heading 4 after macro Jennifer Murphy Word VBA 2 12-14-2015 02:31 AM
VBA Change to correct Heading style Unable to correct auto number of heading 5 KieranWood Word 2 03-03-2011 09:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:26 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