Hi everyone

Hi everyone

Is it possible to load an msword document (and edit/save it) from/to a memorystream in a Delphi application.

Regards.

Comments

  1. kamel mohammed you have two options. You can use COM and automate Word from your Delphi program. Cons; you'll have to use COM, you'll have to have Word installed and possibly target different Word versions (depends on exactly what you want to do - mailmerge calls are not always compatible). This kind of thing IMHO is more suitable for a desktop application. Word will need its hidden windows and stuff and this is possible to put into a server but i do not recommend it.

    As Doug states; the new docx (and Open Office formats for that matter) are zip-files containing parts in an object model. You can use the zip functionality of delphi to traverse the content of the file. You can do changes and then save the file. Microsoft even has an SDK/API for these things (albeit it uses .NET / VC) but it will give good pointers. I use this way to do some processing server-side. Since it's on the server i want all code to be compiled (no loaded libraries- especially not COM); i extract text from Word, Excel and PowerPoint files, i merge/substitute headers and footers from a standard "template" and i manipulate these headers since using fields in word would demand the document be printed from word. Substituting the text allows the timstamps and other stuff (author et. al) to be correctly viewed even om an iPad. Super-con: only the new formats are supported. Oh, and i extract thumbnails.

    For COM i suppose you'll have to store you stream somewhere som your instance of Word can access it (COM might have some streaming possibilities i do not know). If using the docx approach you do not have to go via disks.

    ReplyDelete

Post a Comment