CWinApp* pApp=AfxGetApp();
POSITION templatepos=pApp->GetFirstDocTemplatePosition();
bool bfind=false;
while(pos!=NULL)
{
if(bfind)
break;
CDocTemplate* doctemplate=pApp->GetNextDocTemplate(templatepos);
POSITION docpos=doctemplate->GetFirstDocPosition( );
while(docpos)
{
CDocument* pdoc=doctemplate->GetNextDoc(docpos);
CString docpath=pdoc->GetPathName();
if(docpath=="c:\\tmp\\test.doc")
{
POSITION pos = GetFirstViewPosition();
CView* pFirstView = GetNextView( pos );
CMDIFrameWnd* pFrame=(CMDIFrameWnd*)AfxGetMainWnd();
pFrame->MDIActive(pFirstView);
bfind=true;
break;
}
}
}