在Find.Execute上Word 2013崩溃 [英] Word 2013 Crash on Find.Execute

查看:70
本文介绍了在Find.Execute上Word 2013崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用VSTO ThisAddIn和Word 2013.



我想使用  Find.Execute  和
使用自定义撤消消息标记此操作。代码是:

  < span class ="pln"style ="margin:0px; padding:0px; border:0px; color:#303336"> application    UndoRecord    StartCustomRecord   "Some Message" );   

var 找到 = 申请 ActiveDocument 内容 查找 ;
find
执行 "要替换的字符串"
ReplaceWith < span class ="str"style ="margin:0px; padding:0px; border:0px; color:#7d2727">" second string"
替换 WdReplace wdReplaceAll );

申请
EndCustomRecord ();



所以我在这段代码运行过程中遇到了Word崩溃。如果我改变  替换:
WdReplace.wdReplaceAll
  替换:
WdReplace.wdReplaceOne
,我可以使用单词,但我需要替换所有出现的内容。


< p style ="padding-right:0px;字体大小:15像素;明确:两者;颜色:#242729; font-family:Arial,'Helvetica Neue',Helvetica,sans-serif">
任何建议/解决方法?

解决方案


我使用
测试代码

 private void UndoRecord_Click(object sender,RibbonControlEventArgs e)
{
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(" Some Message");

var find = Globals.ThisAddIn.Application.ActiveDocument.Content.Find;
find.Execute( "要替换的字符串"
,ReplaceWith:" second string"
,Replace:WdReplace.wdReplaceAll);

Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord() ;
}


Word不会在Office2013或Office2016中崩溃。


我建议你测试代码片段并检查它是否会导致问题。


问候,



I'm using VSTO ThisAddIn and Word 2013.

I want to replace all occurences of the one string with another using Find.Execute and mark this action with custom undo message. The code is:

application.UndoRecord.StartCustomRecord("Some Message");

var find = application.ActiveDocument.Content.Find;
find.Execute("string to be replaced"
  , ReplaceWith: "second string"
  , Replace: WdReplace.wdReplaceAll);

application.EndCustomRecord();

So I have a Word Crash during this code run. If I change Replace: WdReplace.wdReplaceAll to Replace: WdReplace.wdReplaceOne, I'll have word working, but I need to replace all occurrences.

Any suggestions/workarounds?

解决方案

Hi,

I test the code using

        private void UndoRecord_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord("Some Message");
 
            var find = Globals.ThisAddIn.Application.ActiveDocument.Content.Find;
            find.Execute("string to be replaced"
              , ReplaceWith: "second string"
              , Replace: WdReplace.wdReplaceAll);
 
            Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
        }

Word would not crash in Office2013 or Office2016.

I suggest you test the code snippet and check if it would cause the issue.

Regards,

Celeste


这篇关于在Find.Execute上Word 2013崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆