View Single Post
 
Old 05-26-2021, 06:38 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Expert
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA converting manual numbering to auto numbering

Hi, I want to update a text to tables macro to include converting all manual numbering that starts at the beginning of a paragraph in the second column e.g. (a), (b), (i), (ii), (A), (B), (1), (2) to the correct auto numbering styles of my template: (a) Definitions Level 1; (i) Definitions Level 2; (A) Definitions Level 3; (1) Definitions Level 4. It also needs to restart numbering when it is related to a new definition. Would anybody be able to help me achieve this in my current macro? I have attached a test Word document so you can see the styles in the styles pane and how they should appear in the second column. Thanks, Shelley

Code:
Sub DPU_TextToTables()
  Dim oBorder As Border
    Selection.WholeStory
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
    NumRows:=8, AutoFitBehavior:=wdAutoFitFixed
    With Selection.Tables(1)
        .Style = "Table Grid"
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        With .Range
            .Font.Name = "Arial"
            .Font.Size = 10
            With .ParagraphFormat
                .SpaceBefore = 0
                .SpaceBeforeAuto = False
                .SpaceAfter = 9
                .SpaceAfterAuto = False
                .LineSpacingRule = wdLineSpaceAtLeast
                .LineSpacing = 15
                .LineUnitBefore = 0
                .LineUnitAfter = 0
            End With
        End With
        With .Columns(1)
            .PreferredWidth = InchesToPoints(2.7)
            .Select
            With Selection.ParagraphFormat
                .Alignment = wdAlignParagraphLeft
                .LeftIndent = InchesToPoints(1)
          End With
            For Each oBorder In .Borders
            oBorder.LineStyle = wdLineStyleNone
            Next oBorder
            End With
        With .Columns(2)
            .Select
            With Selection.ParagraphFormat
                .Alignment = wdAlignParagraphJustify
            End With
            .PreferredWidth = InchesToPoints(3.63)
            For Each oBorder In .Borders
                oBorder.LineStyle = wdLineStyleNone
            Next oBorder
        End With
    End With
End Sub
Attached Files
File Type: docx definitions table.docx (20.9 KB, 15 views)
Reply With Quote