Replacing Tags in a Word Document - XOJO Native Only

Hello Guys,

Is there a way to open a word document, Windows and MAC but only with XOJO, native code, no Plugins option here .

I have some documents that have some parameters like <#Tag#> and those have to be replaced with the actual data.

Thanks in advance.

I did this, but can’t share the code, unfortunately.

It’s not easy, but here are the steps as I remember them:

  • You have to unzip the word document into its component files.
  • Open the right file, which will be XML, and find your tags. Note that the text might be intermingled with formatting code and the like.
  • Change the tags, then zip the whole thing up and rename it with the .docx extension.

You can do the unzipping/zipping entirely in Xojo code use @Thomas Tempelmann 's ZipArchive, or via a Shell on the Mac and OLE on Windows.

Sounds like you try what WordFileMBS class does.

As far as I know you guys have a plugin license, so just use it :slight_smile:

Not this time, this project is separate and because they require full code they don’t want plugins as we know you cannot offer source code for them. Honestly I like XOJO without the plugins it works several times faster than with them. I hope XOJO will do something about this in the future releases and we could use them much easier . Thanks for the advice

[quote=471435:@Kem Tekinay]I did this, but can’t share the code, unfortunately.

It’s not easy, but here are the steps as I remember them:

  • You have to unzip the word document into its component files.
  • Open the right file, which will be XML, and find your tags. Note that the text might be intermingled with formatting code and the like.
  • Change the tags, then zip the whole thing up and rename it with the .docx extension.

You can do the unzipping/zipping entirely in Xojo code use @Thomas Tempelmann 's ZipArchive, or via a Shell on the Mac and OLE on Windows.[/quote]
Thanks Kem, I’ll look into it and see what I will get.

Only install the plugins you need. Maybe you can work with only half of them?

Much easier if they can supply/use RTF as the file format, since you can open that as a text stream.

That is what they use now but they tend to open it in Word as it is more common and have more features and every time it is opened in word it messed all the formatting so they have to redo all again. So what we do now, they do all in Word , export it as RTF and we process the RTF but still I was looking for ways to avoid all that RTF processing .

If you’re working on Windows use theOffice Automation plugin that Xojo already ships with every copy ?
Look in Extras > Office Automation and just install the plugin

[quote=471452:@Norman Palardy]If you’re working on Windows use theOffice Automation plugin that Xojo already ships with every copy ?
Look in Extras > Office Automation and just install the plugin[/quote]
That was an option, Windows is new , Mac is old and still using it for most of the customers , so looking for both platforms . Thanks for that.

curious, what if you created a helper console app using MBS (Also like simulating a dll). That way, you can give them source code of your work which shows references of how it interacts with the helper console app.

just a thought :slight_smile:

It would be an option, I did sent you an email and I guess I have other ideas to have this better maybe , I’ll reply there

I already did like Kem mentionned, but for excel files and it works fine
I suppose it would be almost the same for word.
it takes quite some time though to make it work.