好的,基本上我们在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。
编辑:文档的结构本质上是一组逐项列表,其中包含法律文本,当申诉流程经历各个阶段时,由用户更新。在最后两个部分的每个部分中,逐项列表需要遵循特定的编号方案(num为.5“,文本为1”,右边的标签为1“),这不是Word 2007的原生。每个都有一个粗体标题。作为编号起点的部分。将根据用户的需要添加自动图文集条目。文档的其余部分从我们的数据库中提取信息,并包含文档所需的法律措辞。 如果我能弄清楚如何单独启动每个部分的编号,那么我可以完成它。
答案 0 :(得分:0)
我实际上已经找到了自己的问题解决方案。问题是尝试在编号的第(2)行插入自动图文集条目,因为它读取整行并认为它是自动图文集条目。它不是只读取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