Thread: [Solved] Automatic Words replacement
View Single Post
 
Old 11-22-2014, 05:59 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Replacing randomly is once thing, ensuring balanced percentages amongst the replacements is quite another. For the random replacements, you could use a macro like:
Code:
Sub CheckTherefore()
Application.ScreenUpdating = False
Randomize Timer
Dim strWords As String, i As Long, j As Long, k As Long, bCap As Boolean
strWords = "therefore,in other words,hence,so we can conclude that," & _
   "on this basis we conclude that,that is,so we conclude that"
i = UBound(Split(strWords, ",")) + 1
With ActiveDocument.Range
  With .Find
    .Text = "therefore"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .Execute
  End With
  Do While .Find.Found
    bCap = (UCase(.Characters.First) = .Characters.First)
    Do While j = k
      j = Int(Rnd() * i)
    Loop
    .Text = Split(strWords, ",")(j)
    k = j
    If bCap = True Then .Characters.First = UCase(.Characters.First)
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = False
End Sub
Theoretically, in a large document, the relative frequency of and given replacement will usually be within one standard deviation of the average.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote