Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #20  
Old 07-15-2022, 07:12 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 thank you so much for your help with this. I have since copied the code for the Heading numbering so I can do the same thing with my schedule numbering.
I have changed any reference of Heading in the code to Schedule Level and it works well for ApplyMultiLevelNumbers_A and ApplyMultiLevelNumbers_B but for some reason I am getting a run time error 5167 This is not a valid style name in the code below at the line .LinkedStyle = "Schedule Level " & i - when I click the Reset icon in the VBA window the styles update as they should so I am not sure why this bug is happening - I have checked the spelling, spaces etc and even copied the line from ApplyMultiLevelNumbers_A as that code is working just fine with no errors - do you have any ideas why this would happen?

Code:
Sub ApplyMultiLevelScheduleNumbers_HouseStyle()
    'Add as a call to ApplyScheduleStyles_IfAuto to convert numbering to house style
Application.ScreenUpdating = False
Dim LT As ListTemplate, i As Long
Set LT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
For i = 1 To 8
  With LT.ListLevels(i)
    .NumberFormat = Choose(i, "%1.", "%1.%2", "%1.%2.%3", "%1.%2.%3.%4", "(%5)", "(%6)", "(%7)", "(%8)")
    .TrailingCharacter = wdTrailingTab
    .NumberStyle = Choose(i, wdListNumberStyleArabic, wdListNumberStyleArabic, wdListNumberStyleArabic, _
     wdListNumberStyleArabic, wdListNumberStyleLowercaseLetter, wdListNumberStyleLowercaseRoman, wdListNumberStyleUppercaseLetter, _
      wdListNumberStyleArabic)
    .NumberPosition = 0
    .Font.Bold = Choose(i, 0, 0, 0, 0, 0, 0, 0, 0)
    .Alignment = wdListLevelAlignLeft
    .TextPosition = InchesToPoints(i * 0.5)
    .ResetOnHigher = True
    .StartAt = 1
    .LinkedStyle = "Schedule Level " & i
  End With
  With ActiveDocument.Styles("Schedule Level " & i)
  Select Case i
      Case 1
         .ParagraphFormat.LeftIndent = InchesToPoints(0.5)
      Case 2
        .ParagraphFormat.LeftIndent = InchesToPoints(1)
      Case 3
        .ParagraphFormat.LeftIndent = InchesToPoints(1.5)
      Case 5
        .ParagraphFormat.LeftIndent = InchesToPoints(2.75)
      Case 6
       .ParagraphFormat.LeftIndent = InchesToPoints(3.25)
      Case 7
        .ParagraphFormat.LeftIndent = InchesToPoints(3.75)
    End Select
        .ParagraphFormat.FirstLineIndent = InchesToPoints(-0.5)
    Select Case i
    Case 4
        .ParagraphFormat.LeftIndent = InchesToPoints(2.25)
        .ParagraphFormat.FirstLineIndent = InchesToPoints(-0.75)
    End Select
    .ParagraphFormat.Alignment = wdAlignParagraphJustify
    .Font.Name = "Arial"
    .Font.Italic = False
    .Font.ColorIndex = wdAuto
    .Font.Size = 10
  End With
Next
Application.ScreenUpdating = True

End Sub
Reply With Quote
 



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 01:38 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