View Single Post
 
Old 10-24-2021, 07:12 AM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Graham and thank you for your time. Yes, agreed. The formatting is horrible, but this is what I have to work with. As far as all the other formatting, I can take care of that, just really trying to understand the application of the Heading styles. Here is a cleaned up document and the macro I cobbled together which of course does not work entirely. This is just a shortened version of a 9 page document and then there are another 3 to format. Manual of course is an option, but not one I'm excited about. Can you give some suggestion on this macro and how it can be fixed to cover all of the letter/number combinations?

Code:
Sub ConvertStyle()
    Dim orng        As Range: Set orng = ActiveDocument.Range
    Dim opara       As Paragraph
    Dim oParRng     As Range
    Dim MyLtr       As String
    Dim MyStyle     As String
    
    For Each opara In orng.Paragraphs
        Set oParRng = opara.Range.Duplicate
        MyLtr = oParRng.Characters(1)
            
        Select Case MyLtr

            Case "I", "II", "III", "IV", "V", "VI": opara.Style = "Heading 1"
            Case "A", "B", "C", "D", "E", "F": opara.Style = "Heading 2"
            Case "1", "2", "3", "4", "5", "6": opara.Style = "Heading 3"
            Case "a", "b", "c", "d", "e", "f": opara.Style = "Heading 4"
            
        End Select
            
    Next opara
    
lbl_Exit:
    Exit Sub
End sub
Attached Files
File Type: docx T.docx (25.1 KB, 10 views)
Reply With Quote