使用C#进行office开发中,怎么隐藏Word工具菜单栏

2024-12-22 00:42:02
推荐回答(2个)
回答1:

如今直上银河去,同到牵牛织女家.

回答2:

需要导入Mso9.dll
void CDefineOfficeCtrl::DefineShowHideCommandBar(short iCommandIndex, BOOL bShowHide)
{
MsWord9__Document pDoc;
pDoc.AttachDispatch(pDefineOfficeFrame->pDefineOfficeView->lpDispatch,FALSE);
Mso9__CommandBars pCommandBars;
Mso9_CommandBar pCommandBar;
pCommandBars=pDoc.GetCommandBars();
pCommandBar=pCommandBars.GetItem(COleVariant((short)iCommandIndex));
pCommandBar.SetVisible(bShowHide);
//
pCommandBar.ReleaseDispatch();
pCommandBars.ReleaseDispatch();
pDoc.DetachDispatch();
pDoc.ReleaseDispatch();
}