我想创建一个程序,我必须加载word文档,然后检查checkbox
搜索和替换单词,然后单击一个按钮,然后搜索并替换它
我知道代码是:
private void SearchReplace()
{
Word.Find findObject = Application.Selection.Find;
findObject.ClearFormatting();
findObject.Text = "find me";
findObject.Replacement.ClearFormatting();
findObject.Replacement.Text = "Found";
object replaceAll = Word.WdReplace.wdReplaceAll;
findObject.Execute(ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref replaceAll, ref missing, ref missing, ref missing, ref missing);
}
我如何将其加入checkbox
?
答案 0 :(得分:0)
双击Protect
按钮,将打开其方法。在其中,您可以放置任何您想要的代码。
首先检查是否选中了复选框,然后检查替换空格的代码:
if (checkboxName.Checked == true)
{
SearchReplace();
}