Replace text in word document by VBScript

Hi Everyone.

I have found the sample about replacement text in word document by VBScript as attached file.

But when run, it not replace text which I want.

Pls check and correct me.

Thanks in advance!

replace text.7z (25.1 KB)

1 Like

Hi Everyone.

Thanks you… I have found the mistake.

There is a space in main folder “replace text”… I have changed it into “replacetext” and OK.

I’m glad it’s resolved. If you have any further questions regarding VBS, please reply.

1 Like

Hi Bro.

I have one difficult.

the find text: “cat”
the replaced text: “dog dog”

If the replaced text contains a space between characters… then it not replace.

How to accept space in string when replace text.

Thanks you!

There is usually no problem, the spacebar inside double quotes works fine.

I could tell Chr (34), but I think it is a parameter problem. If you write the code as it is,

A short comment is attached to the code screenshot below, so check it out.


1 Like

Hi Bro.

Sorry, I use text from Excel Column for replacement.

Exp: Row(“Replacement”).ToString ( Cell A1: “Black Dog” )

If I use code as above… it only got “Black” for replacement

It’s not clear how your code is going, but if you want to replace it, try something like this:

  1. Script
    image

  2. Before Run
    image

  3. After Run
    image

PS. If it’s a space issue, you can also do this:
The value was entered, but it may be invisible due to the cell size. In that case, use Autofit.

image
image

2 Likes

Thanks you very much bro :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.