Use VC programming to manipulate office. You can implement such as: Word file printing, transferring data to Word documents, sending e-mail, automatically generating tables, Excel data statistics, pie charts, histogram display, automatic report generation, playback slides, doc,txt,html,rtf file conversion, Chinese simplified traditional conversion, Pinyin or stroke sorting ... As long as the functionality that Office can implement can be invoked in the program you write. Read the instructions below and download the source file for your reference, and you'll be able to take this technique step-by-step. I wish our friends a happy learning.
First, the concept
The interfaces for OLE Automation Automation programs are available in Microsoft Office products. If you use Vb,vba and script scripts to invoke Office functionality, it's much simpler than using VC calls. For example, in Word, bring up the menu "tool (T) \ macro (M) \ Record New Macro (R)", at which point it begins to record any menu and keyboard you have in Word, and save your procedure for repeated calls. The record for saving these operations is actually using the VBA program (Visual Basic for application). The following features we want to implement also refer to the VBA approach.
Second, the structural level
In order to be more logical and more hierarchical to operate Office,microsoft, the application (application) is divided into the following tree structure by logical function
Application (WORD, for example, lists only part)
Documents (all documentation)
Document (one documentation)
......
Templates (All templates)
Template (a template)
......
Windows (All windows)
Window
Selection
View
Selection (Edit object)
Font
Style
Range
......
......
Only by understanding the logical hierarchy can we manipulate Office properly. For example, if a VBScript statement is given:
Application. Activedocument.saveas "C:\abc.doc"
So, we know, the process of this operation is: the first step, to obtain application; The second step, obtains the activedocument from the application; step three, call the document's function SaveAs, and the argument is a string file name.