[请益] BCB透过OLE修改word中文字方块的字串

楼主: heibow (危 险 心 灵)   2013-09-24 00:01:51
大家好
由于准备套印比赛的奖状
须要把bcb程式中run出的奖状内容
套印到奖状样版上 进行打印
OLE的资料 特别是C++的 网络上不好找
找来找去只找到这个(只贴取代字串的部分 开档关档测试是OK的)
但实际执行的结果 只会对样版中的<单位>做取代
如果<单位>是打在文字方块中就搜寻不到
网络上其它OLE控制文字方块的资料都是新增文字方块 不能符合我的须求
请问是否有OLE的高手可以指导一下呢? 谢谢
Variant WordSel=word.OlePropertyGet("Selection");
WordSel.OleFunction("WholeStory");
Variant Replacement,WordFind;
WordFind=WordSel.OlePropertyGet("Find");
WordFind.OleFunction("ClearFormatting");
WordFind.OlePropertySet("MatchCase",false);
WordFind.OlePropertySet("MatchWholeWord",true);
WordFind.OlePropertySet("Text","<单位>");
WordFind.OlePropertySet("Wrap",1);
WordFind.OlePropertySet("Forward",true);
WordFind.OlePropertySet("Format",false);
WordFind.OlePropertySet("MatchByte",true);
WordFind.OlePropertySet("MatchWildcards",false);
WordFind.OlePropertySet("MatchSoundsLike",false);
WordFind.OlePropertySet("MatchAllWordForms",false);
WordFind.OlePropertySet("MatchWildcards",false);
WordFind.OlePropertySet("MatchAllWordForms",false);
Replacement=WordFind.OlePropertyGet("Replacement");
Replacement.OlePropertySet("Text","");
Variant vValue=WordFind.OleFunction("Execute");
while(vValue==Variant(true))
{
WordSel.OleFunction("TypeText","XX高中");
vValue=WordFind.OleFunction("Execute");
}

Links booklink

Contact Us: admin [ a t ] ucptt.com