View Single Post
 
Old 05-27-2021, 03:56 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 convert manual numbering to auto numbering in table

Hi, yes you are quite right, I should have applied specific styles to the two columns. I have created a style called DefBold for Column 1 and DefText for Column 2. I have looked at the code you suggested but I can't understand it or how to apply it to my macro. How can I get the columns to change to these specific styles and possibly add them to the styles pane. The numbering levels (a), (i), (A), (1) then need to update from manual to their correct auto level. How can I do that. These definitions are converted from pdf to Word, I run one macro to do the formatting of the definitions first, check for errors then run the macro below to convert to a table.

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 test doc for definitions table.docx (21.0 KB, 19 views)
Reply With Quote