List VBA WORD如何增加多级列表编号?

List VBA WORD如何增加多级列表编号?,list,vba,ms-word,increment,List,Vba,Ms Word,Increment,我正在寻找一个代码,当我在其他子节点上输入特定的编号时,可以修改列表编号。 我的另一个子从段落中读取一个数字并将其保存为整数。 然后,对于这个整数,我需要做一些事情: 输入列表: 1.5.BLABLABLA 1.5.1.BLIBLIBLI (SOMEWHERE WILL BE A Paragraph with "14" Text, this to integer) 14.5.BLABLABLA 14.5.1.BLIBLIBLI 输出列表: 1.5.BLABLABLA 1.5.1.BLIBLI

我正在寻找一个代码,当我在其他子节点上输入特定的编号时,可以修改列表编号。
我的另一个子从段落中读取一个数字并将其保存为整数。
然后,对于这个整数,我需要做一些事情:

输入列表:

1.5.BLABLABLA
1.5.1.BLIBLIBLI
(SOMEWHERE WILL BE A Paragraph with "14" Text, this to integer)
14.5.BLABLABLA
14.5.1.BLIBLIBLI
输出列表:

1.5.BLABLABLA
1.5.1.BLIBLIBLI
(SOMEWHERE WILL BE A Paragraph with "14" Text, this to integer)
14.5.BLABLABLA
14.5.1.BLIBLIBLI

好吧,我处理得很好

Sub LimpiaTitulos()
    'Normalizador de títulos de nivel determinado(3 en este caso)
    ActiveDocument.Repaginate
    If ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) > 50 Then
         If MsgBox("El documento tiene " & ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) & _
        " páginas." & vbCr & "Esta macro no esta pensada para tantas páginas y puede afectar" & vbCr _
        & "al rendimiento general del ordenador." & vbCr & "¿Desea realmente ejecutarla?", vbYesNo + _
        vbInformation, "Güornin!!!!!") = vbYes Then
            GoTo Comienzo
        Else
            Exit Sub
        End If


    Else
    Comienzo:
    Dim ele As List, iTotalParas As Integer, iParacoutner As Integer, p As Paragraph, numeracion As String
         iTotalParas = ActiveDocument.ListParagraphs.Count


    'Dejamos el primer párrafo con texto, quitando retornos
    Borraespacios
    Set p = ActiveDocument.Paragraphs(1)
    lvl = Int(p.Range.Text)
    p.Range.Delete
    Borraespacios

    'Formato de título
    'Formato de título
        p.Range.Font.Size = 20
        p.Range.Font.Bold = True
        p.Range.Font.Italic = False
        p.Range.Font.Name = "Arial"
        p.OutlineLevel = wdOutlineLevel3

    '-------------------------------------------------REGEX----------------------------------------------------

        Dim lvl1 As New RegExp, lvl2 As New RegExp
        'REGEX primer nivel
        lvl1.Pattern = "[0-9]{1,}[.,][0-9]{1,}[.,][0-9]{1,}" 'Admite #.,#.,# - SUPONEMOS JAMAS HABRA #,.#,.#,.#
        lvl1.Global = False
        'REGEX segundo nivel
        lvl2.Pattern = "[0-9]{1,}[.,][0-9]{1,}" 'Admite #.,#
        lvl2.Global = False
        'Si nos topamos con un nivel 2 de mas caracteres de los deseados, lo tragamos

    '-----------------------------------------------FIN REGEX--------------------------------------------------
                For iParaCounter = 1 To iTotalParas
            '   Cogemos el parrafo actual y lo tratamos


                        Set p = ActiveDocument.ListParagraphs(iParaCounter)
                        'Metemos el formato de la numeración en un String
                            numeracion = p.Range.ListFormat.ListString
                            'Si es de más de 2 carácteres
                            'If Len(numeracion) > 2 Then
                                'Filtramos la numeración con la REGEX
                                If lvl1.test(numeracion) Then
                                    numeración = "1.1.1"
                                Else
                                    If lvl2.test(numeracion) Then
                                        numeracion = "1.1"
                                    Else
                                        GoTo Siguiente
                                    End If
                                End If

                                If p.Range.ListParagraphs.Count = 1 Then
                                        'Borramos el formato y aplicamos el nuevo

                                         p.Range.Select
                                         Selection.ClearFormatting
                                                If Len(numeracion) <= 4 Then

                                                    'p.Range.SetListLevel Level:=2
                                                    p.OutlineLevel = wdOutlineLevel3

                                                Else

                                                    'p.Range.SetListLevel Level:=3
                                                    p.OutlineLevel = 10
                                                End If
                                        'Aplicamos lista multinivel de números
                                        p.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdOutlineNumberGallery).ListTemplates(2), _
                                        ContinuePreviousList:=True, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior

                                        'Establecemos el numero del tema

                                        p.Range.ListFormat.ListTemplate.ListLevels(1).StartAt = lvl

                                        'Si el nivel de esquema es 3, aplicamos lista nivel 2
                                        If p.OutlineLevel = 3 Then
                                                    p.Range.Font.Name = "Calibri"
                                                    p.Range.Font.Size = 14
                                                    p.Range.Font.Bold = True
                                                    p.Range.Font.Italic = False
                                                    '-----SOLO PARA TEST p.Range.Font.ColorIndex = wdBrightGreen
                                                    p.Range.SetListLevel Level:=2



                                        'Si el nivel de esquema es 4, aplicamos lista nivel 3
                                        Else
                                            If p.OutlineLevel = 10 Then
                                                        p.Range.Font.Name = "Calibri"
                                                        p.Range.Font.Size = 12
                                                        p.Range.Font.Bold = False
                                                        p.Range.Font.Italic = False
                                                        '-----SOLO PARA TEST p.Range.Font.ColorIndex = wdBlue
                                                        p.Range.SetListLevel Level:=3

                                            End If
                                        End If

                                End If
                            'End If
    Siguiente:
                Next iParaCounter


    End If
    End Sub
Sub-LimpiaTitulos()
“确定时间的标准化者”(3 en este caso)
ActiveDocument.Repaginate
如果ActiveDocument.BuiltInDocumentProperties(WDPropertyPage)>50,则
如果MsgBox(“El documento tiene”&ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)&_
“páginas.”和vbCr&“不可能是páginas和puede afectar的一部分”&vbCr_
&“阿尔·伦迪曼托·德尔·奥德纳多将军。”&vbCr&“埃切克塔拉的现实”,vbYesNo+_
vbInformation,“Güornin!!!”)=vbYes Then
后藤科米恩佐
其他的
出口接头
如果结束
其他的
科米恩佐:
Dim ele作为列表,iTotalParas作为整数,iParacoutner作为整数,p作为段落,numeracion作为字符串
iTotalParas=ActiveDocument.ListParations.Count
“德贾莫斯·埃尔·普里默·帕拉福·考克斯,基坦多·雷特罗诺斯
博拉埃斯帕西奥斯
Set p=ActiveDocument.段落(1)
lvl=Int(p.Range.Text)
p、 范围。删除
博拉埃斯帕西奥斯
“título格式
“título格式
p、 Range.Font.Size=20
p、 Range.Font.Bold=True
p、 Range.Font.Italic=False
p、 Range.Font.Name=“Arial”
p、 OutlineLevel=WDOutlineLevel 3
“-------------------------------------------------------正则表达式----------------------------------------------------
将lvl1调整为新RegExp,将lvl2调整为新RegExp
“REGEX primer nivel
lvl1.Pattern=“[0-9]{1,}[,][0-9]{1,}[,][0-9]{1,}”'敬佩#,#,#,#-SUPONEMOS JAMAS HABRA#,.#,.#,.##
lvl1.Global=False
“REGEX segundo nivel
lvl2.Pattern=“[0-9]{1,}[,][0-9]{1,}”赞赏##
lvl2.Global=False
“这是第二层的塔帕莫斯,是第二层的塔帕莫斯,是第二层的塔帕莫斯
“-----------------------------------------------------FIN REGEX--------------------------------------------------
对于iParAccounter=1到iTotalParas
“Cogemos el parrafo Really y lo tratamos
Set p=ActiveDocument.ListParents(iParAccounter)
“字符串中的数字格式”
numeracion=p.Range.ListFormat.ListString
“这是两辆车的特点
'如果Len(numeracion)>2,则
“规则的数字过滤器”
如果lvl1.测试(数值),则
numeración=“1.1.1”
其他的
如果lvl2.test(numeracion)则
numeracion=“1.1”
其他的
西吉恩特后藤酒店
如果结束
如果结束
如果p.Range.listPages.Count=1,则
“Borramos el formato和aplicamos el nuevo
p、 范围。选择
Selection.ClearFormatting

如果Len(numeracion)听起来你已经有了一些代码,你能告诉我们到目前为止你得到了什么吗