VB Word宏设置列表项目符号的样式

时间:2019-01-23 17:52:48

标签: vba list outlook ms-word

我将一些文本设置为列表,并且始终以粗黑点显示。我正在努力寻找如何设置以“-”而不是点开头的列表。

设置列表:

oDoc.Paragraphs.Add() '17
iStartIndex = oDoc.Paragraphs.Count
oDoc.Paragraphs.Last.Range.Text = strUmfang
iEndIndex = oDoc.Paragraphs.Count

oDoc.Range( Start := oDoc.Paragraphs(iStartIndex).Range.Start, End := 
oDoc.Paragraphs.Last.Range.End ).Select()

Selection.Range.ListFormat.ApplyBulletDefault

我尝试设置:     ListGalleries.Item(3).ListTemplates(1).ListLevels(1).NumberFormat = ChrW(61485)

它一直显示为黑点。有小费吗 ?谢谢^^

2 个答案:

答案 0 :(得分:1)

当您从录制中得到ListGalleries.Item(3).ListTemplates(1).ListLevels(1).NumberFormat = ChrW(61485)时,您可能更改了样式定义,但从未应用过。

如果再次进行相同的录制并进行检查,您将发现它将其与样式相关联。看起来像.LinkedStyle = "List Paragraph",但可能是德语的行。

将该部分处理到您现有的宏中,然后在选择文档的相关部分后进行

Selection.Style = ListGalleries.Item(3).ListTemplates(1).ListLevels(1).LinkedStyle

答案 1 :(得分:1)

我能够记录一个使用破折号设置新列表样式的宏。为了创建测试,我创建了一个包含5个文本段落的空白文档:

enter image description here

然后,从录制的宏中创建一个单独的clf = ImageClassifier(verbose=True) clf.fit(x_train, y_train, time_limit=12 * 60 * 60) clf.final_fit(x_train, y_train, x_test, y_test, retrain=True) y = clf.evaluate(x_test, y_test) ,以针对使用破折号的列表样式初始化新的Sub

ListTemplate

最后,我的测试代码选择所有段落并列出列表:

Private Function CreateCustomListStyle(ByRef oDoc As Document) As ListTemplate
    With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = ChrW(8210)
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleBullet
        .NumberPosition = InchesToPoints(0.5)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = InchesToPoints(0.75)
        .TabPosition = wdUndefined
        .ResetOnHigher = 0
        .StartAt = 1
        With .Font
            .Bold = wdUndefined
            .Italic = wdUndefined
            .StrikeThrough = wdUndefined
            .Subscript = wdUndefined
            .Superscript = wdUndefined
            .Shadow = wdUndefined
            .Outline = wdUndefined
            .Emboss = wdUndefined
            .Engrave = wdUndefined
            .AllCaps = wdUndefined
            .Hidden = wdUndefined
            .Underline = wdUndefined
            .Color = wdUndefined
            .Size = wdUndefined
            .Animation = wdUndefined
            .DoubleStrikeThrough = wdUndefined
            .Name = "Calibri"
        End With
        .LinkedStyle = ""
    End With
    ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
    Set CreateCustomListStyle = ListGalleries(wdBulletGallery).ListTemplates(1)
End Function

结果:

enter image description here