Hello All
Problem Solved.... The trick is not to use the index but the name of the category...
Here is a function that do that:
int CYourClassName::ActivateCategoryByName( CString strCategoryName)
{
CMainFrame* pMainFrame = ( CMainFrame*) AfxGetMainWnd();
CMFCRibbonBar* pmrb = &pMainFrame->m_wndRibbonBar;
int nCategoryCount = pmrb->GetCategoryCount();
for ( int nCategoryNdx = 0; nCategoryNdx < nCategoryCount; nCategoryNdx++)
{
CMFCRibbonCategory* pmrc = pmrb->GetCategory( nCategoryNdx);
CString strName = pmrc->GetName();
if ( strName == strCategoryName)
{
pmrb->ShowCategory( nCategoryNdx, TRUE);
pmrb->SetActiveCategory( pmrc, TRUE);
return nCategoryNdx;
}
}
return -1;
}
Thierry