Calling Word in the VC to remove Word's common, format toolbar

zhaozj2021-02-17  54

Calling Word in the VC to remove Word's common, format toolbar

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 MSO9.DLL in the Office directory, select _commandbars, commandbar. Click OK

Add #include "mso9.h" in officeview.h.

Add method:

int CQsofficeView :: hidetoolbar (BOOL hide) {TRY {LPDISPATCH lpDisp; lpDisp = m_pSelection-> GetIDispatch (); Documents docs; _Application app; _Document mydoc; _CommandBars mybars; CommandBar mybar; mydoc.AttachDispatch (lpDisp, TRUE); app = Mydoc.getApplication (); mydoc.activate ();

Mybars.attachdispatch (MyDoc.getCommandbars (), true); mybar.attachdispatch (MyBars.GetItem (Colevariant 1) * / "Standard")), true); MyBar.SetVisible (HIDE); MyBar. AttachDispatch (mybars.GetItem (COleVariant (/ * (short) 2 * / "Formatting")), TRUE); mybar.SetVisible (hide); CMDIFrameWnd * pwnd = (CMDIFrameWnd *) AfxGetMainWnd (); pwnd-> GetActiveFrame () -> UpdateWindow ();

} Catch (CEXCEPTION, E) {Tchar ErrorMsg [255]; E-> GetErrorMessage (ErrorMSG, 255, NULL);} end_catchreturn 0;}

After Bulid, after INSERT OBJECT, you can call Hidetoolbar.

My experience: After the macro recording function of Word is recorded, select the tool under the macro VB editor to see its source code and then implement it according to the corresponding class of MSWORD.H and MSO * .h.

Call Word in the VC one here.

http://www.9cbs.net/develop/Article/10570.shtm

I think someone may take a lot of detours like me, and I hope that my Method is hoped to help them. :)

转载请注明原文地址:https://www.9cbs.com/read-30392.html

New Post(0)