宏以突出显示合同中未定义的合同中的黄色全部大写单词。 [英] Macro to highlight yellow all capitalized words in a contract that not defined in the contract.

查看:75
本文介绍了宏以突出显示合同中未定义的合同中的黄色全部大写单词。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一名律师,我写的合同定义了某些在合同中具有特殊意义的词语。  示例:

As a lawyer, I write contracts that define certain words to have special significance in the contract.   Example:

此主服务协议("协议")的有效期为2018年6月6日("生效日期"),由ABC公司("ABC")生成。 )和XYZ公司("XYZ"),在此统称为
"缔约方"。  打算受法律约束的双方同意如下:

This Master Services Agreement ("Agreement") is dated effective as of June 6, 2018 ("Effective Date") and is made by ABC Company ("ABC") and XYZ Company ("XYZ"), who shall collectively be referred to herein as the "Parties."  The Parties, intending to be legally bound, agree as follows:

======合同语言开始样本

======SAMPLE CONTRACT LANGUAGE START

1。服务。   XYZ应在生效日期("期限")开始的12个月内向ABC提供技术咨询服务("服务")。   XYZ应使用专业标准向ABC提供服务,并且b b $ b应在不迟于双方书面双方同意的交付日期之前立即交付所有交付物。

1. Services.  XYZ shall provide technology consulting services ("Services") to ABC for the 12-month period commencing on the Effective Date ("Term").  XYZ shall provide the Services to ABC using Professional Standards and shall deliver all Deliverables promptly no later than the delivery dates mutually agreed by the Parties in writing.

[合同开始on ...]

[Contract goes on...]

======样本合同语言结束

======SAMPLE CONTRACT LANGUAGE END

我试图在上面创建一个突出显示黄色的宏例如,短语"专业标准"和"可交付物"一词因为这些大写术语都没有在本协议的这个片段中定义。  我已经多次尝试过这个宏的
,但是这很麻烦,以至于需要很长的时间来处理,比如60页的合同。  我需要这个宏,所以我可以更好地证明这些合同的最终确定,以确保协议中使用的所有大写术语
都在某个地方定义(即所有大写术语都在协议中的某个地方定义,在引号内)。  

I seek to create a macro that would highlight yellow in the above example, the phrase "Professional Standards" and the word "Deliverables" because neither of those capitalized terms is defined in this snippet of the Agreement.  I've attempted this macro several times, but it's so cumbersome that it takes too long to process, say, a 60-page contract.   I need this macro so I can better proof these contracts for finalization to ensure that all capitalized terms used in the Agreement are defined in it somewhere (i.e. all capitalized terms are defined, within quotes, somewhere in the Agreement).  

由于一些原因,这个问题具有挑战性。  首先,宏不能只看单个大写单词。  例如,"专业标准"是两个单词,有时大写的短语长3或4个单词。  其次,
宏需要忽略某些条件,比如每个段落和每个句子中的第一个大写单词。  第三,宏需要忽略某些通过语法约定大写的单词,例如一周中的几天,几个月和某些
普通专有名词(例如, 

United国")。  在第三点上,我已经加载了一个包含某些专有名词列表的数组,最后一步,让宏取消突出显示任何适用的术语。

This ask is challenging for a few reasons.   First, the macro can't just look at single capitalized words.  For example, "Professional Standards" is two words, and sometimes capitalized phrases are 3 or 4 words long.   Second, the macro needs to ignore certain conditions, like the first capitalized word in every paragraph and every sentence.  Third, the macro needs to ignore certain words that are capitalized by grammar conventions, such as days of the week, months, and certain common proper nouns (e.g., 
United States").  On this third point, I've loaded an array with a list of certain proper nouns and as a last step, have the macro de-highlight any applicable terms.

我寻求帮助在创建计算效率高的宏。  在我的尝试中,我的宏在概念上做了以下内容:

I seek help in creating an computationally EFFICIENT macro.   In my attempts, my macro conceptually did the following:

(1)使用Scripting.Dictionary,宏遍历整个合同,在引号中查找单词和短语(即"定义"术语")并使用脚本字典将它们保存到内存中。

(1) Using a Scripting.Dictionary, macro goes through entire contract looking for words and phrases within quotations (i.e., the "defined terms") and saves them into memory using the Scripting Dictionary.

(2)使用简单的查找/替换例程在合同中突出显示所有大写单词。

(2) Highlights in contract, all capitalized words, using simple find/replace routine.

(3)然后,我循环执行一些子程序,每个子程序都设计为REMOVE突出显示,这样当步骤完成时,所有仍然突出显示的是大写但未定义的单词(总是有一些例外情况,我希望
最小化。)

(3) Then, I cycle through a number of sub-routines, each designed to REMOVE highlighting so that when the steps are complete, all that remains highlighted are the words that are capitalized, but not defined (always with a few exceptions, which I want to minimize).

(4)周期1:删除某些专有名词的突出显示以及其他不适用的大写字词,例如"部,"星期几,美国国家名称等等。

(4) Cycle 1: Remove highlighting for certain proper nouns and other capitalized terms that won't be applicable, like "Section," days of the week, names of US States, etc.

(5)周期2:删除所定义的所有术语的突出显示。  在这里,我使用查找/替换例程来删除每个定义的术语或短语的突出显示,方法是循环遍历Scripting.Dictionary中的每个术语或短语并将其去除高亮显示。

(5) Cycle 2: Remove highlighting for all terms that ARE defined.   Here, I use a find/replace routine to remove highlighting for each defined term or phrase, by looping through each term or phrase in the Scripting.Dictionary and de-highlighting it.

(6 )周期3:删除每个段落和句子中第一个单词的突出显示。 [*我没有足够的技能来有效地编写这个例程,我认为这一步骤是导致整体执行陷入困境的因素之一,因为我循环通过协议中的每个
句子,选择第一个单词,

(6) Cycle 3: Remove highlighting for the first word in each paragraph and sentence. [* I don't have the skills to program this routine efficiently, and I think this step is one of the ones that bogs down the overall execution because I cycle through each sentence in the Agreement, select the first word, and de-highlight it.

(7)周期4:从所有"截面标题"中删除突出显示。  在法律合同中,章节标题通常是大写的,但对于本练习,不应突出显示这些章节标题。  例如,"1。  服务。 XYZ应......,"
" 2。付款条件。   ABC应支付所有发票......," "2.1发票,税收和延迟付款条款。  所有发票均为......" [在上文中,大写术语"服务", "付款条款",和"发票,
税收和延迟付款条款。"不应该突出显示。] [*同样,我没有编程技巧来有效地执行这个例程,它也使整个执行过程陷入困境。]

(7) Cycle 4: Remove highlighting from all "Section Headers."  In legal contracts, section headers are usually capitalized, but for this exercise, these section headings should NOT be highlighted.  E.g., "1.  Services. XYZ shall....," "2. Payment Terms.  ABC shall pay all invoices...," "2.1 Invoices, Taxes and Late Payment Terms.  All invoices shall be..." [in the foregoing, capitalized terms "Services," "Payment Terms," and "Invoices, Taxes and Late Payment Terms." should NOT be highlighted.] [*Again, I don't have the programming skills to efficiently perform this routine, and it too bogs down overall execution.]

请帮忙!  在他看来,我被锁定在上述概念框架中,无法想出更有效地实现预期最终结果的替代方法。  关于如何更好地完成这个宏项目的任何想法?

Please help!  At his point I'm locked into the above conceptual framework and can't think of alternative ways to more efficiently achieve the desired end result.   Any ideas on how to better go about accomplishing this macro project?

推荐答案

见第二个&第3个宏:  http://www.msofficeforums。 com / word / 12090-need-macro-make-list-defined-terms.html#post32031
这些宏一起构建一个表格,其中包含文档中所有双引号的术语,包括页面他们出现在哪。为了您的目的,您需要设置lCol = 1.这或多或少达到您想要的效果(1),不同之处在于它是
未存储在内存中(您可能会发现它对无论如何都要在你的文档中列出这样的术语。)

See the 2nd & 3rd macros in: http://www.msofficeforums.com/word/12090-need-macro-make-list-defined-terms.html#post32031 Together, these macros build a table of all the double-quoted terms in the document, including the pages on which they appear. For your purposes, you'll want to set lCol = 1. This more-or-less achieves what you want with (1), the difference being that it's not stored in memory (and you may find it useful to have a list of such terms in your document anyway).

然后你可以使用通配符查找/替换来突出显示以大写字母开头的所有单词,其中: br />
查找=< [AZ] [A-Za-z] @>

替换= ^&

并设置替换突出显示选项 。这可以达到你想要的效果(2) 。   (4)& (5) - 见下文 - 也处理这个。

You can then use a wildcard Find/Replace to highlight all words beginning with capitals, where:
Find = <[A-Z][A-Za-z]@>
Replace = ^&
and you set the replacement highlight option. This achieves what you want with (2). The macro for (4) & (5) -see below - handles this, too.

完成后,您可以使用以下宏从文档中找到的所有单词中删除突出显示在第一个宏生成的"定义的术语"表中。如果您将排除项添加到该表中,它们也会被处理,
这可以达到你想要的效果(4)& (5)

Having done that, you can use the following macro to remove the highlighting from all words in the document that are found in the 'defined terms' table produced by the first macro. If you add your exclusions to that table, they'll be processed, too. This achieves what you want with (4) & (5).

Sub HiliteUndefined()

Application.ScreenUpdating = False

Dim oTbl As Table,i As Long

Options.DefaultHighlightColorIndex = wdBrightGreen

With ActiveDocument.Range

 设置oTbl =。表(.Tables.Count)

 有.Find

    .ClearFormatting

    .Format = False

    .Forward = True

    .Wrap = wdFindContinue

    .MatchWildcards = True

    .Text ="< [A-Z] [A-Za-z] @>" b
   使用.Replacement

      .ClearFormatting

      .Text =" ^&"

      .Highlight = True

   结束与$
    .Execute Replace:= wdReplaceAll

   使用.Replacement

      .ClearFormatting

      .Highlight = False

   结束与$
 结束与$
 对于i = 2 To oTbl.Rows.Count

   有.Find

      .Text = Split(oTbl.Cell(i,1).Range.Text,vbCr)(0)

      .Execute Replace:= wdReplaceAll

   结束与$
 下一个

结束用于
Application.ScreenUpdating = True

End Sub

Sub HiliteUndefined()
Application.ScreenUpdating = False
Dim oTbl As Table, i As Long
Options.DefaultHighlightColorIndex = wdBrightGreen
With ActiveDocument.Range
  Set oTbl = .Tables(.Tables.Count)
  With .Find
    .ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Text = "<[A-Z][A-Za-z]@>"
    With .Replacement
      .ClearFormatting
      .Text = "^&"
      .Highlight = True
    End With
    .Execute Replace:=wdReplaceAll
    With .Replacement
      .ClearFormatting
      .Highlight = False
    End With
  End With
  For i = 2 To oTbl.Rows.Count
    With .Find
      .Text = Split(oTbl.Cell(i, 1).Range.Text, vbCr)(0)
      .Execute Replace:=wdReplaceAll
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub

你在问什么对于(6)是有问题的,因为一个或多个单词的未定义的关键词实际上可以开始一个句子。也就是说,下面的宏应该让你相当接近:

What you're asking for (6) is problematic, since an undefined key term of one or more words may in fact start a sentence. That said, the following macro should get you fairly close:

Sub ClearSentenceHilites()

Application.ScreenUpdating = False

With ActiveDocument .Range

 有.Find

    .ClearFormatting

    .Format = True

    .Highlight = True

    .Forward = True

    .Wrap = wdFindStop

    .MatchWildcards = False

    .Text =""

    .Replacement.Text =""

    。执行

 结束与$
  Do While .Find.Found

   如果.Start = .Sentences(1)。开始然后是
     如果.Words.First.Next.HighlightColorIndex = wdNoHighlight则为
        .HighlightColorIndex = wdNoHighlight

     否则

        Do While .Words.Last.Next.HighlightColorIndex<> wdNoHighlight

          .End = .Words.Last.Next.Words.First.End

       循环

     结束如果是
   否则

      .HighlightColorIndex = wdNoHighlight

   结束如果是
    .Collapse wdCollapseEnd

    .Find.Execute

 循环

结束与
Application.ScreenUpdating = True

End Sub

Sub ClearSentenceHilites()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Format = True
    .Highlight = True
    .Forward = True
    .Wrap = wdFindStop
    .MatchWildcards = False
    .Text = ""
    .Replacement.Text = ""
    .Execute
  End With
  Do While .Find.Found
    If .Start = .Sentences(1).Start Then
      If .Words.First.Next.HighlightColorIndex = wdNoHighlight Then
        .HighlightColorIndex = wdNoHighlight
      Else
        Do While .Words.Last.Next.HighlightColorIndex <> wdNoHighlight
          .End = .Words.Last.Next.Words.First.End
        Loop
      End If
    Else
      .HighlightColorIndex = wdNoHighlight
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub

这个宏实际上可以从执行(4)&处理的那个宏调用。 (5)。

如果您的标题使用了标题样式,请执行以下操作宏将删除任何突出显示 。这可以达到你想要的效果(7)

Sub ClearHeadingHilites()

申请。 ScreenUpdating = False

Dim i As Long

With ActiveDocument.Range

 有.Find

    .ClearFormatting

    .Format = True

    .Highlight = True

    .Forward = True

    .Wrap = wdFindContinue

    .MatchWildcards = False

    .Text =""

   使用.Replacement

      .ClearFormatting

      .Text =""

      .Highlight = False

   结束与$
   对于i = 1到9

      .Style =" Heading" &安培;我是
      .Execute Replace:= wdReplaceAll

   下一个

 结束与$
结束与
Application.ScreenUpdating = True

结束子

Sub ClearHeadingHilites()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Format = True
    .Highlight = True
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = False
    .Text = ""
    With .Replacement
      .ClearFormatting
      .Text = ""
      .Highlight = False
    End With
    For i = 1 To 9
      .Style = "Heading " & i
      .Execute Replace:=wdReplaceAll
    Next
  End With
End With
Application.ScreenUpdating = True
End Sub

这个宏也可以从执行(4)&的处理的那个调用。 (5),或者从处理(6)的那个开始。

在上面是带有各种突出显示的单词的文档之后,你会留下什么?你要检查。

What you'll be left with after the above is a document with various highlighted words for you to check.


这篇关于宏以突出显示合同中未定义的合同中的黄色全部大写单词。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆