3

How can I replace, say, 250 out of 1000 words in Microsoft Word?

For example, 'happy' is written about 1000 times in my document. I want to replace only 250 of them with the word 'joy'.

So is there a function or way to do that at once in Microsoft Word?

9
  • 8
    I don't know the answer, but can I ask why? – DM_with_secrets Jan 11 at 7:54
  • 12
    So you want some chance for "I am happy to announce" to become "I am joy to announce" ? Not useful for making your paper have more word variation but would be useful for an ESL test! That being said I have no idea if word allows custom functions like excel does, but such a thing would be trivial in python, r, or most programming languages for that matter. – eps Jan 11 at 17:32
  • 18
    @eps When I was a kid, we went to McDonalds I ate my first joy Meal on my birthday. I was very joy. Then we sang: joy birthday to you! joy birthday to you! joy birthday, dear immibis! joy birthday to you! Then my aunt said, because it was close to Christmas, "joy holidays"! but I corrected her and told her she was being too politically correct, and it should be "merry Christmas and a joy New Year!" – user253751 Jan 11 at 17:47
  • 4
    Replacing happiness with joy would work. Happy's an adjective, though, and joy is a noun. Are you looking for joyful? – wizzwizz4 Jan 11 at 21:29
  • 3
    People are taking this question far too literally I think. My guess is we're looking at a Ren & Stimpy reference. (I don't think you're joy enough. I'll teach you to be joy...) I assume those were just example words. – Darrel Hoffman Jan 11 at 22:08
16

The quickest way is to do a "Find" (Ctrl+F) and cycle through each individual instance and select replace when you wish to replace the instance with "Joy".

5
  • 1
    @User999 I agree. My editor kept picking words I overused, and this gives you the review of all of them, so you decide which to keep and which to dump, one at a time (repetitive, but accurate). But it's not going to be random. You'll need to choose. – DWKraus Jan 11 at 14:14
  • I guess you could flip a coin for each of them. :) – Llewellyn Jan 11 at 19:16
  • 8
    When you get down too it, at this stage, it might be that a random number a spaced far enough apart that they would be unremarkable, but there are clusters where you really need to break out a thesurus. Don't just replace 1/4 of the total words with another synonym. – hszmv Jan 11 at 19:35
  • 2
    This. You don't want to ramdomply replace some of them, but the search highlights them ALL so you see where they cluster and then you can replace (manually) some of them there – Hobbamok Jan 12 at 12:18
  • 1
    This is a good answer, partly because it's non-technical (much as I love programmatically editing Word docs, cough cough), and partly because it preserves the human factor needed to not make this an exercise in futility. – Luke Sawczak Jan 12 at 17:44
4

This solution will probably be more programming intensive than what you are looking for but I'll put in out there is case it is of use to someone. MS Word just stores a document as a zip file with a .docx extension. You can unzip it with standard utilities. The zip file contains a number of xml files as well as other files that hold formatting information. The body of the document is stored in a file called document.xml. Since this is a text file it is possible to write an application to do a search and replace on only a specific number of matches and then re-zip the file and rename it with a .docx extension. As was mentioned earlier this could also be also be done with one of the Visual Basic/C languages using VSTO but there may be more of a learning curve if you haven't used it before.

4

Here is a method directly in Word for replacing every 3rd, then every 5th occurrence of "happy" with "joy'. After you record one macro (to make an average of 25% swaps), you run a second macro once that runs the first one to document end:

  1. Record a macro, naming it MacroJoy1 (View / Macros / Run Macro). Use Ctl-H (not -F) to find the next "happy." Click "Find Next". Click "Find Next". Replace "happy" with "joy".

Click "Find Next". Click "Find Next". Click "Find Next". Click "Find Next". Click "Find Next". Replace "happy" with "joy". Stop Recording.

  1. Record MacroJoy2, which runs MacroJoy1 125 times. Number can be higher. Stop recording.

  2. Run MacroJoy2!

1
  • 1
    You could change this into instructions for incorporating the RND function linked in my answer, for randomization of how many times a macro / function repeats... – Malady Jan 12 at 1:33
3

It's a bit of a pain, but as far as I know there is no such function native to MS Word. Besides that, you'll probably be best off using CTRL+F and reviewing each case individually for context, rhythm, etc. before making changes -- indiscriminate machine replacement will probably make more problems than it solves.

2
  • 4
    Perhaps it calls for some kind of script? VBA? – Peter Mortensen Jan 11 at 20:44
  • @PeterMortensen I'm afraid I wouldn't know. Maybe! – dweeblet Jan 12 at 1:35
3

Yeah, like other people are saying, making a VBA Macro is the way to go:

https://support.microsoft.com/en-us/office/create-or-run-a-macro-c6b99036-905c-49a6-818a-dfb98b7c3c9c


Something like using the Find function, then randomly, with the RND function, going some number of spaces ahead, and then replacing the selection with the word you want.

0

Only manually, or by subjecting your Word document to a programming language… which for any single instance will almost certainly be at least as difficult.

To the extent you can re-use it the idea becomes more efficient, though no more easy.

Word itself has no conception of how to replace X out of Y words.

1
  • 1
    The programming language of choice to subject it to is certainly the MSOffice built-in VBA. No additional program required, access to all Word features. It's difficult the first time, perhaps; but going through 1000 find locations in a Word document is a serious pain. – Peter - Reinstate Monica Jan 12 at 16:24
0

Not random, but no special tools required. To replace every fourth occurrence (case sensitive):

  • Find and Replace > Replace

  • Use wildcards = checked

  • Find: (<happy>*)(<happy>*)(<happy>*)<happy>

  • Replace: \1\2\3joy

  • Replace All

With (some) case insensitivity:

  • Find and Replace > Replace

  • Use wildcards = checked

  • Find: (<[Hh]appy>*)(<[Hh]appy>*)(<[Hh]appy>*)<[Hh]appy>

  • Replace: \1\2\3JOY

  • Replace All

  • Match case = checked

  • Find: JOY

  • Replace: (joy|Joy, as required)

(The repeat function ({3}, {1,3}) doesn't like wildcards (*), so multifind statements like this have to be manually created.)

This can be made pseudorandom by replacing multiple times and with different occurrences (e.g. every 7th, then every 5th). The Find and Replace input boxes are limited to 256 characters, so there's only so many that can be done in one go (19 in this case). But any more than every 7th results in the error 'The Find What text contains a Pattern Match expression which is too complex':

  • (<[Hh]appy>*)(<[Hh]appy>*)(<[Hh]appy>*)(<[Hh]appy>*)(<[Hh]appy>*)(<[Hh]appy>*)<[Hh]appy>
  • \1\2\3\4\5\6JOY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.