I have a word document template that I need to do a find and replace on.
For example I need to replace <address 1> with 1 Test Street.
I have tried doing this using a macro which I can run from command line but you don’t seem to be able to pass in arguments and therefore cannot edit either the pattern you are searching for or the thing to replace it with.
I need to it using PHP ultimately so had been looking for something I can just call with an exec, I did find a library called PHPWord that looked very useful but the way it worked was to parse the .doc file into an xml file and this wasn’t working properly resulting in words being split in half and therefore no good for a str_replace.
Finally I looked at using VBScript, I have no experience with this at all and could not get it to work.
Why don’t you use Interop to access the Word document.
You will have to use .NET for this, and you can create a console application.
Have a look at Interop Class Namespace and this for an example.