With this, you can replace the Word menu :) that is, you can complete the Word Framework completely.
In the View menu, select ClassWizard, select the Automation tab, select the ADD Class, select from a type, select Microsoft Word 97/2000 Type Library Word8.OLB or Word9.OLB in the Office directory, select Dialog, Dialogs, Selection. Click OK
The dialog box calling Word is as follows:
TRY {LPDISPATCH lpDisp; if (m_pSelection) {lpDisp = m_pSelection-> GetIDispatch (); Documents docs; _Application app; _Document mydoc; mydoc.AttachDispatch (lpDisp, TRUE); app = mydoc.GetApplication (); mydoc.Activate () Dialogs mydialogs; dialog mydialog; mydialogs.attachdispatch (app.getdialogs (), true); mydialog.attachdispatch (MyDialogs.Item (112), TRUE);
/ * 112 is a lookup replacement * / mydialog.show (Colevariant ((Short) 0)); mydialog.execute (); mydialog.detachdispatch ();
}}}} Catch (CEXCEPTION, E) {/ * Your pleaser to display error message * / tchar errormsg [255]; E-> getErrorMessage (ErrorMSG, 255, null);} end_catchreturn 0;
/ * In Word recorded new macro, enter Dialogs (this time you will automatically select one, then select one and then right click on the definition. You can view it. You can view it. 79, open files 80, page settings Is it 178 and so on? Look at the literals. If you don't make it, just one to try it. Replace the above 112 to you. SHOW (Colevariant ((Short) 0) is always displaying, Until the user makes a choice to set the number of milliseconds you want. * /
Below is a specific code (with Copy & Paste):
int CQsofficeView :: adjustpage (int oldstartpage, int totalpages, int nowstartpage, BOOL downorup) {TRY {LPDISPATCH lpDisp; if (m_pSelection) {lpDisp = m_pSelection-> GetIDispatch (); Documents docs; _Application app; _Document mydoc; mydoc.AttachDispatch (LPDISP, TRUE); App = mydoc.getApplication (); mydoc.activate (); selection myselection; myselection.attachdispatch (app.getSelection () (); MySelection.goto (Colevariant (short) 1), Colevariant ( (Short) 2), Colevariant (Short) 0); MySelection.Movedown (Colevariant (Short) 7), Colevariant (Short) Totalpages, Colevariant (Short) 2) ); MySelection.cut (); MySelection.goto (Colevariant (short) 2), Colevariant (Short) 0), Colevariant (Short) NowstartPage); MySerection.Paste () }} Catch (CEXCEPTION, E) {/ * Your pleaser to display error message * / tchar error [255]; E-> getErrorMessage (ErrorMsg, 255, null);} end_catch Return 0;}
It's too happy, so put the source code to the source.
There is no problem in implementing Word function technology. There will be such a document in the future. :)