选择我正在输入的单词 [英] Select the word i'm typing

查看:62
本文介绍了选择我正在输入的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的。你告诉我怎么才能听到我输入的字。

i'm new to this.can you tell me how can i catch the word i'm typing in word.

推荐答案

你好
Kazi Fazlee Rabbi,

看起来你想要找到"我正在打字"这个词。在word文档中。

its looks like you want to find the word "i'm typing" in word document.

你可以通过选择对象或范围对象找到它。

you can find it by selection object or by range object.

使用选择对象:

 private void SelectionFind() 
        { 
            object findText = "find me";

            Application.Selection.Find.ClearFormatting();

            if (Application.Selection.Find.Execute(ref findText,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, 
                ref missing, ref missing)) 
            { 
                MessageBox.Show("Text found.");
            } 
            else
            { 
                MessageBox.Show("The text could not be located.");
            } 
        }


 

使用Range  object:

 

using Range object:

 private void RangeFind() 
        { 
            object findText = "find me";

            Word.Range rng = this.Paragraphs[2].Range; 

            rng.Find.ClearFormatting();

            if (rng.Find.Execute(ref findText,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, 
                ref missing, ref missing)) 
            { 
                MessageBox.Show("Text found.");
            } 
            else 
            { 
                MessageBox.Show("Text not found.");
            } 

            rng.Select(); 
        }

参考:

如何:以编程方式搜索和替换文档中的文本

问候

Deepak


这篇关于选择我正在输入的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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