This macro applies list-style numbering to the rows inside your tables so numbered levels line up cleanly after export.

The numbering of rows in a table basically works like the usual numbering in Lawlift, namely via levels. In order to identify these levels within the table, the expression ”[#]” is used. Here ”[#]” defines the 1st level, ”[##]” the 2nd level, ”[###]” the 3rd level and so on. All nine levels provided by Word can be used. Which numbering is finally inserted must be determined beforehand in a list format template within the letterhead. The name of the list format template is of particular importance, as the name is used in the macro. In our case, the list was named “A. / 1 . / 1.1.”. However, you can also give the list a different name and adapt the macro code accordingly.

If you have any questions about this, please contact our support team at support@lawlift.de.

Below you will find a sample code that applies the numbering defined in the list format template to the paragraphs within a table. These paragraphs must first be marked with [#], [##], etc. in the Lawlift template. As soon as the macro is executed, the numbering is added in the corresponding places. Please note that the numbering outside the table is also taken into account here.

Strictly speaking, the code example consists of two different sub-routines. The first determines that all numbering levels are aligned to the left. This ensures a clear presentation within the table, where there is often not much space for indentations. The second sub-routine then converts all paragraphs marked with the [#] commands into numbered paragraphs and is based on the numbering previously defined in the list format template “A. / 1 . / 1.1.”.

Note: Run the macro manually after exporting the file from Lawlift. If you wish to run it automatically, rename the macro to “AutoOpen”. This has the effect that the macro is automatically executed when the Word file is opened.

If there are a large number of expressions in the document, the execution may take a few seconds.

Sub Level_setting_A_1_11()

Dim X As Integer
Const newNumPos As Long = 0
Const newTextPos As Long = 0

With ActiveDocument.Styles("Liste3").ListTemplate
    For X = 1 To 9
        .ListLevels(X).TextPosition = newTextPos
        .ListLevels(X).NumberPosition = newNumPos
    Next
End With

End Sub

Sub Nummerierung_Numeric_with_Zero_indentation()

Dim Level As Integer
With ActiveDocument.Range.Find
    .Text = "\[#*\]"
    .MatchWildcards = True

Do While .Execute
If .Parent.Information(wdWithInTable) Then
    Level = Len(.Parent.Text) - 2
    .Parent.Style = ActiveDocument.Styles("Liste3")
    .Parent.ListFormat.ListLevelNumber = Level
    
    If Not Level = 1 Then
        .Parent.ListFormat.ListTemplate.ListLevels(Level).TextPosition = 0
        .Parent.ListFormat.ListTemplate.ListLevels(Level).NumberPosition = 0
    End If
    
    .Parent.Delete

End If
Loop

.MatchWildcards = False
End With

End Sub
    

Run the macro: see How to insert and run a Word macro.