Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Find and replace in multiple Word documents

  • 18-10-2018 04:24PM
    #1
    Closed Accounts Posts: 925
    ✭✭✭


    Hi everyone :-)

    I've been recently given the task of updating multiple Word documents by finding and replacing certain text so far, I've built 2 macros, which has greatly speeded up things, but still, it's taking a long time due to the amount of files that have to be updated. Is there a free utility or perhaps someone here has a script that can perform a find and replace across multiple Word documents.


Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Registered Users, Registered Users 2 Posts: 911 heffsarmy
    ✭✭✭


    A simple python script would do the job or drag them into a linux environment and use command line, e.g. sed -i 's/oldword/newword/g' file.doc. You could install cygwin on windows and run the bash commands against the doc files.

    to find all the files in current directory

    find . -name "*.doc" -exec sed -i 's/oldword/newword/g' {} \;


  • Registered Users, Registered Users 2 Posts: 611 brianwalshcork
    ✭✭✭


    Will send work on a docx where the content of the file is compressed and not plain text?


  • Banned (with Prison Access) Posts: 1,480 bloodless_coup
    ✭✭✭


    heffsarmy wrote: »
    A simple python script would do the job or drag them into a linux environment and use command line, e.g. sed -i 's/oldword/newword/g' file.doc. You could install cygwin on windows and run the bash commands against the doc files.

    I doubt it's that simple seeing as word docs are not plain text.


  • Registered Users, Registered Users 2 Posts: 911 heffsarmy
    ✭✭✭


    doylefe wrote: »
    I doubt it's that simple seeing as word docs are not plain text.

    True actually, a quick google and you will find ways.

    https://stackoverflow.com/questions/34779724/python-docx-replace-string-in-paragraph-while-keeping-style


  • Closed Accounts Posts: 22,648 beauf
    ✭✭✭✭


    RHJ wrote: »
    Hi everyone :-)

    I've been recently given the task of updating multiple Word documents by finding and replacing certain text so far, I've built 2 macros, which has greatly speeded up things, but still, it's taking a long time due to the amount of files that have to be updated. Is there a free utility or perhaps someone here has a script that can perform a find and replace across multiple Word documents.

    You might need to rewrite the macro to perform better. They shouldn't generally be slow unless you are using selections instead of object ranges. If you record your actions and just modify it you may be using too many selects.

    If you want a hand pm me.


  • Advertisement

Welcome!

It looks like you're new here. Sign in or register to get started.
Advertisement