比如说word中有一段文字“$%某学校%$期末考试”,我想把“$%某学校%$”替换成“ABC小学”,用VC++的MFC开发,要使用word.olb的哪些类?怎么使用其中的成员函数?有没有具体的例子(代码)?   万分感谢!!!

解决方案 »

  1.   

    我的vc++代码是(部分代码):Find myfind;     CComVariant FindText=(_T("$%某学校%$")); 
        CComVariant MatchCase(false); 
        CComVariant MatchWholeWord(false); 
        CComVariant MatchWildcards(false); 
        CComVariant MatchSoundsLike(false); 
        CComVariant MatchAllWordForms(false); 
        CComVariant Forward(true); 
        CComVariant Warp(_T("wdFindContinue")); 
        CComVariant Format(false); 
        CComVariant ReplaceWith(_T("ABC小学")); 
        CComVariant Replace(_T("wdReplaceAll")); 
        CComVariant MatchKashida(false); 
        CComVariant MatchDiacritics(false); 
        CComVariant MatchAlefHamza(false); 
        CComVariant MatchControl(false);  myfind.Execute(&FindText,&MatchCase,&MatchWholeWord,&MatchWildcards,&MatchSoundsLike,&MatchAllWordForms,&Forward,&Warp,&Format,&ReplaceWith,&Replace,&MatchKashida,&MatchDiacritics,&MatchAlefHamza,&MatchControl);
    编译无错误,但是运行后没有效果,仍然没有替换,请高手指教,谢谢!