【问题标题】:multilevel list without indentation in word vbaword vba中没有缩进的多级列表
【发布时间】:2021-08-08 21:24:40
【问题描述】:

我有一个宏,可以在文档中搜索[#] 并使其成为列表编号,具有多级。每个主题标签代表级别编号。即

  • [#] 级别 1 - - 结果 - -> 1.
  • [##] 2 级 -- 结果 --> 1.1.
  • [###] 3 级 -- 结果 --> 1.1.1。

所以它工作得很好。但我不希望我的文本缩进,而是保持在缩进级别。因为我的文本在表格中,所以缩进时会很疯狂。

工作代码在这里:

Sub Nummerierung_Numeric()

'Makro Written by M.B.A

Dim Level As Integer

    With ActiveDocument.Range.Find 'or Selection.Range.Find
        .Text = "\[#*\]"
        .MatchWildcards = True
        
        Do While .Execute
        If .Parent.Information(wdWithInTable) Then
                Level = Len(.Parent.Text) - 2
                .Parent.Style = ActiveDocument.Styles("1 / 1.1 / 1.1.1")
                .Parent.ListFormat.ListLevelNumber = Level
                .Parent.Delete
        End If
        Loop
        
        .MatchWildcards = False
    End With
End Sub

【问题讨论】:

  • 您将他们应用的样式更改为没有缩进的onre。这样做最合乎逻辑的方法是定义一个 brew sret 样式,这些样式继承自您当前使用的样式,但具有不同的缩进规则。

标签: vba list ms-word indentation multi-level


【解决方案1】:

您可以修改1 / 1.1 / 1.1.1 样式设置,使使用此样式的任何段落都没有缩进,但请注意,这可能会影响您可能需要缩进的段落(在这种情况下,您需要为此定义一个新样式)目的):

    Const newNumPos As Long = 0
    Const newTextPos As Long = 18 'Change as required, this is the Text Indent (in Points)
    
    With ActiveDocument.Styles("1 / 1.1 / 1.1.1").ListTemplate
        .ListLevels(1).TextPosition = newTextPos
        .ListLevels(1).NumberPosition = newNumPos
        
        .ListLevels(2).TextPosition = newTextPos
        .ListLevels(2).NumberPosition = newNumPos
                
        .ListLevels(3).TextPosition = newTextPos
        .ListLevels(3).NumberPosition = newNumPos
    End With

【讨论】:

  • 虽然这不是我问题的答案,但是你给了我一个好主意。我很感激。谢谢!
  • @IbneAshiq 那你得解释一下remain in their indent level,这是什么意思?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-07
相关资源
最近更新 更多