Use Automation to manipulate Word and Excel in VC
Recently, you have to add a program to the image and data from the program to the word. Enter keyword Word get n posts. After reading, you can learn that there are two ways to do what I need, one is the method of using Office's own type library, the other is to use COM's Automation technology. After two ways, since there are too many classes that need to be imported using the type library, it is not good for different OFFICE versions of compatibility, so the automation technology in my program is used. The method is determined, the next is the specific encoding.
Firstly, deport data to Word, refer to Q238393 in MSDN to get an autowrap function, which is most useful. Then refer to Q220911 to get the method of operation of Word, such as drawing, input text, branch, etc., but the Q220911 is provided in the use of type libraries (in fact, the two is very small, if you trace into mword.h If you'll find that in msword.h is the automation invoke function to call each attribute or method's distribution ID to implement, but it has been encapsulated, so open the VC comes with the tool Oleviewer and Office itself. The VBA Chinese help, and also uses the B2Cse.exe provided by the Q216388 in the MSDN to convert VBA to C code. After several working days, I finally reached the effect I demand.
Re-implement the ability to export data to Excel, this requirement is relatively simple. The basic method is the same, and AutoWrap is also used. For the operation of Excel, the Q216686 is used, and the Excel is filled with SafeArray. It has also reached the requirements soon.
Summarized, I don't know what you can get from this article?