从Excel VBA重新启动Word Doc的列表编号

时间:2017-08-18 15:28:05

标签: excel vba excel-vba ms-word

我有一个带有矩阵的电子表格,如果有一个" X"那么第一列中的文本将被实现到一个内置的Word文档中。在与该行文本相同的行中的单元格中。从这里开始,我列出了带有标题的列表,但是在每个标题后重新启动列表时都会遇到问题。

以下是我尝试重新启动列表的代码。在End If(列表库)之前的最后一个项目之前,它不会返回任何错误。有人可以帮忙吗?

                If Range("A" & X - 1).Value = "Heading" Then
                        With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
                            .NumberFormat = "(%1)"
                            .TrailingCharacter = wdTrailingTab
                            .NumberStyle = wdListNumberStyleLowercaseLetter
                            .NumberPosition = CentimetersToPoints(2)
                            .Alignment = wdListLevelAlignLeft
                            .TextPosition = CentimetersToPoints(2.63)
                            .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 = wdColorBlack
                                .Size = wdUndefined
                                .Animation = wdUndefined
                                .DoubleStrikeThrough = wdUndefined
                                .Name = ""
                            End With
                            .LinkedStyle = "SOWSubList"
                        End With
                        ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""
                        objWord.ActiveDocument.Characters.Last.Select
                        Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
                            ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:= _
                            True, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _
                            wdWord10ListBehavior
                End If
                objWord.Selection.TypeParagraph 'move to the next line

0 个答案:

没有答案