0

好的,所以基本上我们在 Word 2007 的启用宏的模板中有几个独特的部分,对于每个部分,我们有 2 个表单标准条目,然后有大约 20 个可选条目,它们都由自动图文集处理. 模板和自动图文集条目之间的格式相同,我想在添加条目时自动编号(通过用户键入自动图文集关键词或点击功能区上的按钮插入它)。是否有捷径可寻?这是处理这些(编号)条目之一的代码块,以及我尝试从其他论坛上的其他建议中实现的编号方案(在这里找不到任何有用的东西):

    Case "cboFF"
                        SetMargins 0, 1, 1
                        Selection.ParagraphFormat.Space1
                        Selection.Text = "FINDINGS OF FACT" & vbLf
                        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
                        Selection.Font.Bold = True
                        Selection.Font.Underline = wdUnderlineSingle
                        Selection.Collapse (wdCollapseEnd)
                        Selection.Text = vbLf
                        Selection.ParagraphFormat.SpaceAfter = 6
                        Selection.Collapse (wdCollapseEnd)
                        Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
                        Selection.Font.Underline = wdUnderlineNone
                        Selection.Font.Bold = False
                        SetMargins 0, 1, 1
                        'With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
                        '.NumberFormat = "%1."
                        '.TrailingCharacter = wdTrailingTab
                        '.NumberStyle = wdListNumberStyleNone
                        '.NumberPosition = InchesToPoints(0.5)
                        '.Alignment = wdListLevelAlignLeft
                        '.TextPosition = InchesToPoints(0.5)
                        '.ResetOnHigher = 0
                        '.StartAt = 1
                        'AutoNumberOnFOF
                        Selection.Text = "On " & strDateFOF & ", an industrial appeals judge certified that the parties agreed to include the Jurisdictional History in the Board record solely for jurisdictional purposes." & vbLf
                        Selection.ParagraphFormat.SpaceAfter = 6
                        Selection.Collapse (wdCollapseEnd)
                        Select Case strCaseCategory
                            Case "IND", "IND SELF-I"
                                 If frmIIOD.optII.Value = True Then
                                    Selection.Text = "II-FF"
                                    Selection.Range.InsertAutoText
                                    Selection.Collapse (wdCollapseEnd)
                                    Selection.Text = vbLf
                                    Selection.ParagraphFormat.SpaceAfter = 6
                                    Selection.Collapse (wdCollapseEnd)
                                    GoToEnd
                                End If
                                If frmIIOD.optOD.Value = True Then
                                    Selection.Text = "OD-FF"
                                    Selection.Range.InsertAutoText
                                    Selection.Collapse (wdCollapseEnd)
                                    Selection.Text = vbLf
                                    Selection.ParagraphFormat.SpaceAfter = 6
                                    Selection.Collapse (wdCollapseEnd)
                                    GoToEnd
                                End If
                                If frmIIOD.optNotNeeded.Value = True Then
                                    Selection.Text = vbLf
                                    Selection.ParagraphFormat.SpaceAfter = 6
                                    Selection.Collapse (wdCollapseEnd)
                                End If
                            Case Else
                                'Do Nothing
                        End Select

任何建设性的意见将不胜感激,以帮助解决这个问题。我对整个编程仍然很陌生,我的大部分经验都在 C# 和 Java 上。

编辑:文档的结构本质上是一组包含法律文本的逐项列表,当上诉过程经历各个阶段时,用户会对其进行更新。在最后 2 节中的每一个中,逐项列表都需要遵循特定的编号方案(数字为 0.5",文本为 1",右制表符为 1"),这不是 Word 2007 所固有的。每个都有一个粗体标题作为编号起点的部分。自动图文集条目将根据用户的需要添加。文档的其余部分从我们的数据库中提取信息并包含文档所需的法律措辞。如果我能弄清楚如何分别为每个部分启动编号,然后我可以完成它。

4

1 回答 1

0

我实际上已经找到了自己的解决方案。问题是试图在编号的(第二)行插入一个自动图文集条目,因为它读取整行并认为它是一个自动图文集条目。它不仅仅是读取 ii-ff 或 od-ff,而是读取 1. ii-ff,这不是有效的自动图文集条目(按名称)。

                    Case "cboFF"
                        SetMargins 0, 1, 1
                        Selection.ParagraphFormat.Space1
                        Selection.Text = "FINDINGS OF FACT" & vbLf
                        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
                        Selection.Font.Bold = True
                        Selection.Font.Underline = wdUnderlineSingle
                        Selection.Collapse (wdCollapseEnd)
                        Selection.Text = vbLf
                        Selection.ParagraphFormat.SpaceAfter = 6
                        Selection.Collapse (wdCollapseEnd)
                        Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
                        Selection.Font.Underline = wdUnderlineNone
                        Selection.Font.Bold = False
                        SetMargins -0.5, 1, 1
                        'AutoNumberOn
                        Selection.Text = "1." & vbTab & "On " & strDateFOF & strEntry1 & vbLf
                        Selection.ParagraphFormat.SpaceAfter = 6
                        Selection.Collapse (wdCollapseEnd)
                        Select Case strCaseCategory
                            Case "IND", "IND SELF-I"
                                 If frmIIOD.optII.Value = True Then
                                    Selection.Text = "2." & vbTab & strIIEntry & vbLf
                                    Selection.ParagraphFormat.SpaceAfter = 6
                                    Selection.Collapse (wdCollapseEnd)
                                    Selection.Text = "3." & vbTab & "" & vbLf
                                    Selection.Collapse (wdCollapseEnd)
                                End If
                                If frmIIOD.optOD.Value = True Then
                                    Selection.Text = "2." & vbTab & strODEntry & vbLf
                                    Selection.Text = "3." & vbTab & "" & vbLf
                                    Selection.Collapse (wdCollapseEnd)
                                End If
                                If frmIIOD.optNotNeeded.Value = True Then
                                    Selection.Text = "2." & vbTab & "" & vbLf
                                    Selection.ParagraphFormat.SpaceAfter = 6
                                    Selection.Collapse (wdCollapseEnd)
                                End If
                            Case Else
                                'Do Nothing
                        End Select

这允许在空行中插入自动图文集条目,并继续使用 Word 2007 不具备的预格式化编号系统。现在我只需要找出在插入的选择中突出显示特定单词的最简单方法。不应该太糟糕:

    'set array of text entries (6)
    'begin loop
    'find and highlight entry(i)
    'end loop
于 2013-06-27T17:45:55.513 回答