Replacing Tags in a Word Document - XOJO Native Only

  1. 2 weeks ago

    Aurelian N

    Jan 14 Pre-Release Testers, Xojo Pro

    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.

  2. Kem T

    Jan 14 Pre-Release Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    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 @ThomasTempelmann 's ZipArchive, or via a Shell on the Mac and OLE on Windows.

  3. Christian S

    Jan 14 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Sounds like you try what WordFileMBS class does.

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

  4. Aurelian N

    Jan 14 Pre-Release Testers, Xojo Pro

    @ChristianSchmitz WordFileMBS

    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

  5. Aurelian N

    Jan 14 Pre-Release Testers, Xojo Pro

    @Kem T 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 @ThomasTempelmann 's ZipArchive, or via a Shell on the Mac and OLE on Windows.

    Thanks Kem, I'll look into it and see what I will get.

  6. Christian S

    Jan 14 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

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

  7. Jeff T

    Jan 14 Pre-Release Testers Midlands of England, Europe

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

  8. Aurelian N

    Jan 14 Pre-Release Testers, Xojo Pro

    @Jeff T 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 .

  9. Norman P

    Jan 14 Pre-Release Testers, Xojo Pro outside

    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

  10. Aurelian N

    Jan 14 Pre-Release Testers, Xojo Pro

    @Norman P 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

    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.

  11. Rich H

    Jan 14 Pre-Release Testers, Xojo Pro
    Edited 2 weeks ago

    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 :)

  12. Aurelian N

    Jan 15 Pre-Release Testers, Xojo Pro

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

    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

  13. Jean-Yves P

    Jan 15 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    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.

or Sign Up to reply!