作者heibow (危 险 心 灵)
看板Programming
标题[请益] BCB透过OLE修改word中文字方块的字串
时间Tue Sep 24 00:01:51 2013
大家好
由於准备套印比赛的奖状
须要把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");
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.4.77.100
※ heibow:转录至看板 C_and_CPP 09/24 11:47