Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Jim , 18th November 05:23
  2.  
  3. Hi!
  4.  
  5. Sarah , 19th November 06:03
  6.  
  7. Hello there
  8.  
  9. Public Sub ColorMeRedBlue()
  10. Selection.HomeKey Unit:=wdStory
  11.  
  12. color_the_text = False
  13.  
  14. For Each line_in_para In ActiveDocument.Paragraphs
  15.  
  16. text_in_line = line_in_para.Range.Text
  17. check_name = Split(text_in_line, " ")
  18.  
  19. If InStr("Jim", check_name(0)) Then
  20. color_the_text = False
  21. ElseIf InStr("Sarah", check_name(0)) Then
  22. color_the_text = True
  23. End If
  24.  
  25. If color_the_text = False Then
  26. Selection.HomeKey Unit:=wdLine
  27. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
  28. Selection.Font.Color = wdColorRed
  29. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
  30. Selection.EndKey Unit:=wdLine
  31. Selection.MoveDown Unit:=wdLine, Count:=1
  32. ElseIf color_the_text = True Then
  33. Selection.HomeKey Unit:=wdLine
  34. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
  35. Selection.Font.Color = wdColorBlue
  36. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
  37. Selection.EndKey Unit:=wdLine
  38. Selection.MoveDown Unit:=wdLine, Count:=1
  39. End If
  40.  
  41. Next line_in_para
  42.  
  43. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement