Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2014, 03:06 AM
psychologist psychologist is offline Automatic Words replacement Windows 7 32bit Automatic Words replacement Office 2010 32bit
Novice
Automatic Words replacement
 
Join Date: Nov 2014
Posts: 3
psychologist is on a distinguished road
Default Automatic Words replacement

Hello, could you help me create macros for automatic words replacement.
Namely random Words replacement, ie,
For example, the word "therefore" is found 100 times in document. Whether it can be replaced in a random order by these words
-in other words
-hence
-So we can conclude that
-Therefore we can conclude that
-on this basis we conclude that
-that is,
-So we conclude that

but the word "therefore" must be in text too. For example, 100 words is 100%
We have 8 words respectively. It is necessary that it was 12% of the words "in other words", 12% words of "hence", 12% words of "So we can conclude that" ...and so on
12 * 7 = 84
and 16 percent of words "therefore"
but all these words must be randomly distributed in the text.
How Can this be done?
I'm sorry, i'm not programmist, i m just psychologist and don't know how it can realize, but i need it for my scientific work
Reply With Quote
  #2  
Old 11-22-2014, 05:59 AM
macropod's Avatar
macropod macropod is offline Automatic Words replacement Windows 7 64bit Automatic Words replacement Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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
  #3  
Old 11-22-2014, 06:43 AM
gmaxey gmaxey is offline Automatic Words replacement Windows 7 32bit Automatic Words replacement Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

I ran Paul's code on a sample of 100 instances "therefore" with the following results:

therefore - 15
hence - 20
that is - 13
on this basis we can conclude - 17
so we can conclude that - 14
so we conclude that - 10
in other words - 11

You will need to consider context of course. Some of the replacements would looks silly in say:


The pool is only 6 inches deep. We therefore strictly prohibit diving from either side.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 11-22-2014, 11:40 AM
psychologist psychologist is offline Automatic Words replacement Windows 7 32bit Automatic Words replacement Office 2010 32bit
Novice
Automatic Words replacement
 
Join Date: Nov 2014
Posts: 3
psychologist is on a distinguished road
Default

macropod, the biggest thank you, it' s really working, the goal is achieved
gmaxey,
for me it's not so critically in context of this task. Trust me, i know what i do
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Control replacement font in advance? Katten03 Word 6 07-13-2016 04:24 AM
Automatic Words replacement automatic entering of multiple words cliff@tauruscommercial.ca Word 5 06-03-2014 06:06 PM
VBS Image Replacement - Appearing as Gray Box with Filename Twily Office 1 09-12-2013 11:12 PM
Replacement lostsoul62 Excel 0 04-14-2012 10:07 AM
Replacement Software hirize Office 0 08-28-2008 02:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft