word 宏代码编写的问题

word 宏代码编写的问题:关于 .Find.Execute replace:=wdReplaceOne , 我在cb写了:Find.OleFunction("Execute", "replace:=wdReplaceOn
楼主zjsxszj(沈智江)2003-11-20 15:47:07 在 C++ Builder / 基础类 提问
Sub   replace()  
          Selection.Find.ClearFormatting  
          Selection.Find.Replacement.ClearFormatting  
          With   Selection.Find  
                  .Text   =   ""  
                  .Replacement.Text   =   "123456789"  
                  .Forward   =   True  
                  .Wrap   =   wdFindAsk  
                  .Format   =   False  
                  .MatchCase   =   False  
                  .MatchWholeWord   =   False  
                  .MatchByte   =   True  
                  .MatchWildcards   =   False  
                  .MatchSoundsLike   =   False  
                  .MatchAllWordForms   =   False  
          End   With  
    
          Selection.Find.Execute  
    
          With   Selection  
                  If   .Find.Forward   =   True   Then  
                          .Collapse   Direction:=wdCollapseStart     ?  
                  Else  
                          .Collapse   Direction:=wdCollapseEnd         ?  
                  End   If  
                  .Find.Execute   replace:=wdReplaceOne               ?  
                  If   .Find.Forward   =   True   Then  
                          .Collapse   Direction:=wdCollapseEnd         ?  
                  Else  
                          .Collapse   Direction:=wdCollapseStart     ?  
                  End   If  
                  .Find.Execute  
          End   With  
    
    
  End   Sub  
    
String   strText   =   "W";  
  String   strReplaceText   =   "M";  
    
  Variant   find   =   WordApp.Exec(PropertyGet("Selection")).Exec(PropertyGet("Find"));  
  find.Exec(Procedure("ClearFormatting"));  
  find.Exec(PropertyGet("Replacement")).Exec(Procedure("ClearFormatting"));  
    
  find.Exec(PropertySet("Text")<<strtext.c_str());  
  find.Exec(PropertyGet("Replacement")).Exec(PropertySet("Text")<<strreplacetext.c_str());  
  find.Exec(PropertySet("Forward")<<(Variant)true);  
  find.Exec(PropertySet("Wrap")<<(Variant)1);   //wdFindContinue  
  find.Exec(PropertySet("Format")<<(Variant)false);  
  find.Exec(PropertySet("MatchCase")<<(Variant)false);  
  find.Exec(PropertySet("MatchWholeWord")<<(Variant)false);  
  find.Exec(PropertySet("MatchByte")<<(Variant)true);  
  find.Exec(PropertySet("MatchAllWordForms")<<(Variant)false);  
  find.Exec(PropertySet("MatchSoundsLike")<<(Variant)false);  
  find.Exec(PropertySet("MatchWildcards")<<(Variant)false);  
  find.Exec(PropertySet("MatchFuzzy")<<(Variant)false);  
    
  find.Exec(Function("Execute")<<2);//wdReplaceAll
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值