Loading/Saving Word Docs

BlitzMax Forums/BlitzMax Programming/Loading/Saving Word Docs

Ghost Dancer(Posted 2010) [#1]
I know this has been asked before but I've yet to find a solution. Has anyone found or created a solution for loading and/or saving Word documents (primarily .doc but .docx would also be useful)? Ideally I'd like a cross-platform solution but for now I would be happy with Windows only.

I've searched for existing DLLs but have been unsuccessful so far. I did think about writing a DLL in VB and then writing a Max wrapper for it but then realised Max cannot currently use ActiveX DLLs (but please correct me if I'm wrong).

On a similar note the same could be done in .Net but from posts I've read, a similar problem exists trying to use .Net DLLs with Max (plus I'd have to learn .Net).

I have downloaded the MS-DOC specification and could write it myself but this is not a desirable option lol, mainly due to the time it will take but its also a little daunting.

Any advice or suggestions would be greatly appreciated. Thanks.


DrDeath(Posted 2010) [#2]
I have downloaded the MS-DOC specification and could write it myself but this is not a desirable option lol, mainly due to the time it will take but its also a little daunting.

For sure. Microsoft (deliberately?) makes it very difficult for third parties to fully support their formats. I think, they still haven't released the whole OOXML specifications (.docx, .xlsx, and do on) despite that format being allegedly "open". You will find that even professional, commercial software that's supposed to be MS Office compatible has huge problems to properly open and display Office documents.

I'm afraid you won't have very much success with your aim.


nrasool(Posted 2010) [#3]
Hey there,

Really DrDeath? Our company uses PHPExcel to generate documents which can be opened by Excel 2007 without any issue, see http://phpexcel.codeplex.com/

An 2007 document is just a zip file with xml files, if you downloaded 7zip you can get an 2007 document (.docx) and unzip it, and see the structure.

See http://www.developerfusion.com/article/6170/read-and-write-open-xml-files-ms-office-2007/ for more information on the structure

Kind Regards


xlsior(Posted 2010) [#4]
Brucey has ported a module somewhere that can write .xlsx , but I've never seen one that can read/write .doc

As far as writing an importer yourself: good luck, you'll need it.

The biggest problem is that the specs are absolutely pointless in many places, with countless references to "render the same was as word 95 did" and similar madness. Even OpenOffice still isn't 100% compatible with microsoft word since so much had to be reverse engineered the hard way.

Part of the problem is that the older versions of word saved pretty much by taking a dump of the working memory, with horrible documentation along the way...

depending on what you are trying to accomplish: .rtf (which can be read/written without problems by word) is a LOT more straightforward to decypher, and well documented.


TaskMaster(Posted 2010) [#5]
Generating a excel spreadsheet or word document is one thing. Reading one is completely different animal.

You can easily generate these files, using what spec is available and only needing to support the features you are writing. But being able to read a document is a larger issue. You have to be able to deal with ANY possible markup that might be in the file. You have to support he WHOLE spec, not just a small part.


xlsior(Posted 2010) [#6]
And to make matters infinitely more complex: reading arbitrary documents can also involve having to run embedded VBA (Visual Basic for Applications) macros and the likes...


DrDeath(Posted 2010) [#7]
Really DrDeath? Our company uses PHPExcel to generate documents which can be opened by Excel 2007 without any issue,...

I was talking about the other way round: opening something that is more than a very basic document produced with Word/Excel/PowerPoint/whatever in another, non-MS program.


Ghost Dancer(Posted 2010) [#8]
Thanks for your replies. For both writing and reading I am only dealing with text, text formatting and styles.

For the writing part, my app publishes a file in a variety of formats. I've already got it writing RTF files but most users will need to output as .doc as the file will usually be sent to a publisher who require the document in a specific format (which they import into whatever software they use).

Its a real shame Max can't use ActiveX DLLs as I could easily do what I need in VB or .Net.


beanage(Posted 2010) [#9]
Erm.. cant you run .Net in Wine? I guess Ziggy has a lot of experience there.


DrDeath(Posted 2010) [#10]
Erm.. cant you run .Net in Wine?

Actually, no. Or only with lots of problems.