View Single Post
 
Old 01-19-2021, 02:09 PM
gmaxey gmaxey is online now Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

For a common process, you could make the docCurrent a module level variable and then pass arguments to:


Code:
Sub ProcessTable(oTbl As Table, strStartWord As String, strEndWord As String, strUser As String)
Dim oRng As Row
Dim strKeyword As String, strRule As String
  For Each oRow In oTbl.Rows
    strKeyword = Split(Trim(oRow.Range.Cells(1).Range.Text), vbCr)(0)
    strRule = Split(Trim(oRow.Cells(2).Range.Text), vbCr)(0)
    If strKeyword <> "" Then
      Set oRng = GetDocRange("DETAILED", "CLAIMS") 'make docCurrent a module level varialbe
      Set oRngScope = oRng.Duplicate
      With oRng.Find
        .Text = strKeyword
        Do While .Execute
          If Not oRng.InRange(oRngScope) Then Exit For
          oRng.HighlightColorIndex = wdTurquoise
          If strRule <> "" Then
            Set cmtRuleComment = m_oDocCurrent.Comments.Add(Range:=oRng, Text:=strUser & ": " & strRule)
            cmtRuleComment.Author = UCase("WordCheck")
            cmtRuleComment.Initial = UCase("WC")
          End If
        Loop
      End With
    End If
  Next oRow
End Sub
Function GetDocRange(startWord As String, endWord As String) As Range
Dim oRng As Word.Range, iStart As Long, iEnd As Long
  Set oRng = m_oDocCurrent.Range
  With oRng.Find
    .Text = startWord
    If .Execute Then iStart = oRng.End
    oRng.End = aDoc.Range.End
    .Text = endWord
    If .Execute Then iEnd = oRng.Start
    If startWord = "ABSTRACT" Then iEnd = aDoc.Range.End
    If iEnd > iStart Then
      Set GetDocRange = aDoc.Range(iStart, iEnd)
    End If
  End With
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote