How to (quick) replace multiple strings in Word Document

Hello,
I am working on automation where I need to replace multiple strings in Word document. At the moment I am using Word Application Scope + Replace. This works fine but sometimes I need to replace more than 50 strings so it takes almost a minute per document. Also, I will need to work with > 300 000 documents …

I was trying:

  • to use VBA (using excel) - not supported
  • to convert word into an HTML format and replace string here - this will crush the formatting

The thing is I need to preserve the format of the Word Document. So I cannot use string replace and insert replaced text back.

And at the top of that, I am more than curious if anyone was working with PowerPoint automation? Is there any shortcut instead of “click automation”?

Any ideas?

Thank you very much, guys.

Best regards

Jakub

Hi @jakubvanhara

Welcome back! :slight_smile:

Recently a new activity was introduced - Invoke VBScript
With this activity you might run any VBScript on your files.

See a small example here:
ReplacingWordWordsVBScript.zip (11.9 KB)

Hi Maciej!

Thank you for your message and points. I did not update some dependencies so I did not notice this activity. My bad!

But still even with this activity, it takes seconds to replace one word:

obrazek

I would say it takes same time like Word App Scope + Replace :confused:

I think that is as ‘native’ as one can get, unfortunately. However, I am sure some optimization could still be done on the script part to make the changes happen faster.

Not sure if you’ve used my sample script, but it saves the file after each change which would slow things down (for example).