I wrote an abstraction class to generate complex MS Word document from SAP. This class is delivered “ready to use” and cover, i hope, a large panel of usage.
Why this class ?
OLE syntax is not easy and find help is a pain. I learned all i need to know and, to never have to do it again, i have written this class.
Now to write text into word, i simply use the method “write_text” or “write_table” to write a complete table 😉
What you can actually do with the class :
- Create document from scratch or with a template (dotx)
- Write text with or without style (font style or paragraph style)
- Use option bold, italic, underline, choose font, font size, font color
- Break line, Break page, Section, section continuous
- Write table, with or without Table style, and option to define format by cell (bold, background color…)
- Write simple header/footer
- Choose orientation landscape/portrait
- Add image
- Add canvas
- Insert table of content
- Insert custom field
- Change the title of the word window
- Save document and close word
As OLE is an old method, and seem to be a little slow for big document (in particular if you have a lot of table). So this class could be used to help all people that have a problem with OLE syntax, it contain almost all solutions 😉
In the download, you will find a test program that contain the class CL_WORD and a sample of how to use it. You will find also some image and 1 template. Theses files are used by the test program, but are not necessary for the class itself.
French presentation can be found here : Faire communiquer SAP et MS WORD grâce à OLE – Quelquepart
And there is a direct download link (remember that you will need SAPLINK to install) : http://quelquepart.biz/telechargements&file=L2RhdGEvbWVkaWFzL1pDTF9XT1JEX09MRS56aXAqOGQwZmVh&source=SCN-OLE
Feel free to comment here 🙂
My others blogpost :