document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. Sub AAA_underline_uber()
  4. \'
  5. \' underline_fluong Macro
  6. \' Find instances of text from searchTextArray which are not underlined and:
  7. \'  - extend selection to end of line`
  8. \'  - underline it
  9. \'
  10.  
  11. Dim searchTextArray(1 To 4) As String
  12. searchTextArray(1) = "fluong@"
  13. searchTextArray(2) = "blah@"
  14. searchTextArray(3) = "root@"
  15. searchTextArray(4) = " >> Subcase"
  16.  
  17. Dim iCount As Integer
  18. Dim searchText As Variant
  19. Dim Found As Boolean
  20.  
  21. For Each searchText In searchTextArray
  22.     iCount = 0
  23.     Found = True
  24.     Do While Found And iCount < 1000
  25.         iCount = iCount + 1
  26.         \'goto beginning of document
  27.        Selection.HomeKey Unit:=wdStory
  28.         \'perform search
  29.        With Selection.Find
  30.             .ClearFormatting
  31.             .Forward = True
  32.             .Wrap = wdFindContinue
  33.             .Text = searchText
  34.             .Font.Underline = wdUnderlineNone
  35.             .Execute
  36.         End With
  37.         Selection.Find.Execute
  38.         Found = Selection.Find.Found
  39.         \'underline if found
  40.        If Found Then
  41.             Selection.EndOf Unit:=wdLine, Extend:=wdExtend
  42.             Selection.Font.Underline = wdUnderlineSingle
  43.         End If
  44.     Loop
  45.    
  46. Next searchText
  47.  
  48.        
  49. End Sub
  50.  
  51.  
  52. Sub ABA_highlight_test_results()
  53. \'
  54. \' highlight_test_results Macro by @francisluong
  55. \' Find instances of "Test Result:" which are not highlighted and:
  56. \'  - extend selection to end of line`
  57. \'  - highlight it
  58. \'
  59.  
  60.     Dim iCount As Integer
  61.     Dim searchDone As Boolean
  62.     Dim searchTextArray(0 To 0) As String
  63.     Dim searchText As Variant
  64.     searchTextArray(0) = "Test Result:"
  65.     Options.DefaultHighlightColorIndex = wdYellow
  66.    
  67.     For Each searchText In searchTextArray
  68.    
  69.         Selection.HomeKey Unit:=wdStory
  70.                
  71.         searchDone = False
  72.         iCount = 0
  73.        
  74.         Do While searchDone = False And iCount < 1000
  75.            
  76.             iCount = iCount + 1
  77.              
  78.             Selection.HomeKey Unit:=wdStory
  79.             With Selection.Find
  80.                 .ClearFormatting
  81.                 .Forward = True
  82.                 .Wrap = wdFindContinue
  83.                 .Text = searchText
  84.                 .Highlight = False
  85.             End With
  86.             Selection.Find.Execute
  87.            
  88.             If Selection.Find.Found Then
  89.                 Selection.EndOf Unit:=wdLine, Extend:=wdExtend
  90.                 Selection.Range.HighlightColorIndex = wdYellow
  91.             Else: searchDone = True
  92.             End If
  93.         Loop
  94.     Next searchText
  95.        
  96. End Sub
  97.  
  98. Sub ABB_highlight_brute()
  99. \'
  100. \' Find instances of text from searchTextArray and:
  101. \'  - extend selection to end of line`
  102. \'  - highlight it
  103. \'  - dumb search and doesn\'t depend on not found
  104.  
  105. Dim searchTextArray(1 To 1) As String
  106. searchTextArray(1) = "Test Result:"
  107.  
  108. Dim iCount As Integer
  109. Dim searchText As Variant
  110. Dim Found As Boolean
  111. Dim lastPage As Integer
  112. Dim thisPage As Integer
  113.  
  114. For Each searchText In searchTextArray
  115.     iCount = 0
  116.     lastPage = 0
  117.     thisPage = 0
  118.     Found = True
  119.     \'goto beginning of document
  120.    Selection.HomeKey Unit:=wdStory
  121.     With Selection.Find
  122.         .ClearFormatting
  123.         .Forward = True
  124.         .Wrap = wdFindStop
  125.         .Text = searchText
  126.     End With
  127.     Do While Selection.Find.Execute And lastPage <= thisPage And iCount < 99999
  128.         iCount = iCount + 1
  129.         \'perform search
  130.        Found = Selection.Find.Found
  131.         lastPage = thisPage
  132.         thisPage = Selection.Information(wdActiveEndPageNumber)
  133.         \'underline if found
  134.        If Found Then
  135.             Selection.EndOf Unit:=wdLine, Extend:=wdExtend
  136.             Selection.Range.HighlightColorIndex = wdYellow
  137.             lastPage = thisPage
  138.             thisPage = Selection.Information(wdActiveEndPageNumber)
  139.         End If
  140.         Selection.EndKey
  141.                
  142.     Loop
  143.    
  144. Next searchText
  145.  
  146.        
  147. End Sub
  148.  
  149. Sub ACA_snipsnip_bold_italic()
  150. \'
  151. \' Find instances of "-- snip, snip --" which and:
  152. \'  - replace with same text in bold and italic
  153. \'
  154. \'
  155.  
  156. Dim searchTextArray(1 To 1) As String
  157. searchTextArray(1) = "-- snip, snip --"
  158.  
  159. Dim iCount As Integer
  160. Dim searchText As Variant
  161. Dim Found As Boolean
  162.  
  163. For Each searchText In searchTextArray
  164.  
  165.     With ActiveDocument.Content.Find
  166.         .ClearFormatting
  167.         .Text = searchText
  168.         With .Replacement
  169.             .ClearFormatting
  170.             .Font.Bold = True
  171.             .Font.Italic = True
  172.         End With
  173.         .Execute Format:=True, Replace:=wdReplaceAll
  174.     End With
  175.  
  176. Next searchText
  177.  
  178. End Sub
');