{oapdf_gg}
Save Word document
Although the environment has been embedded into the Word application, Word document has been opened and displayed, but if you use the wizard to generate the "Save" function to save the current open Word documents can only save an empty document. This is because the current procedures embedded in Word interface after the "file" menu is a package container program, and the Word in the absence of associated documents can not be implemented before the preservation of function. In its response function in order to add the following code to complete the preservation of the document:
The core idea of this code is through the use of IPersistFile interface Save () method to preserve the current document. Since the method of the first parameter is a variable LPOLESTR to see the definition of the macro can be aware of the variables is a point to wide-character buffer pointer from CFileDialog Class Member Functions GetPathName () the return path CString type can not directly use the document to be through MultiByteToWideChar () function will convert the content type to a WCHAR array. Its first parameter specified by CP_ACP package to use ANSI encoding, the second parameter set to indicate MB_COMPOSITE have been using composite characters. Behind the four variables were the source buffer's address, size and purpose of the address and the size of the buffer zone. Summary
Compiler implementation of the procedure, when the program will open the Word document automation services dynamic start Word, then the mouse will be in a wait state, when the mouse back to normal mode, Word has been embedded into the process, the toolbars and menus are added to many Word tools and menus, can they improve on the Word document to provide support and services. This procedure in the Windows 2000 Professional by Microsoft Visual C + + 6.0 compiler through. Program need to have Microsoft Word 97 or Word 2000 support. |