如何突出以上和在word文档中使用vsto的表中的文本之后

问题描述:




你可以帮助我.......

我对VSTO很新,但是&nbsp ;很好,在.NET 2013.我想知道 - 在VSTO for MS Word中, 

我如何  突出显示&在word文档中的表格的文本之后。 

How can i highlight above & after text of a table in word document. 

我想通过一个文字  检查上面的&在点击按钮后通过下一个按钮后,他们移动到下一个缺少的
文本....它会丢失上面和上面出现的特定默认文本。在桌子后面,

I want to check ony by one text above & after in table through next button when click on button they move to next missing text ....that get missing specific default text which is present on above & on after table ,

如果缺少任何标签,则突出显示当前表格 

默认值(如[[abc]])

test1

test2

test4

test3

默认值(如[[pqr]])




test5

test6

test8

test7

默认值(如[[pqr]])

默认值(如[[abc]])

test5

test6

test8

test7

在form1中。 cs

In form1.cs

当点击下一个按钮移动到下一个缺失的文本并且  突出显示 表

when click on next button move to next missing text and highlight table

我想首先检查缺失的文本,然后突出显示缺失文本表

请帮助我

嗨Sona,

Hi Sona,

你对"上面和后面"和"缺失文字表"的意思是什么?根据你的描述,你似乎想要找到一个字符串并突出显示字符串,如果是这样,我建议你使用Range.Find。

What do you mean with "above & after" and "table of missing text"? Based on your description, it seems you want to find a string and highlight the string, if so, I suggest you use Range.Find.

这是一个简单的代码:

Here is a simple code:

        private void button1_Click(object sender, EventArgs e)
        {
            Range range = Globals.ThisAddIn.Application.ActiveDocument.Content;
            object findText = "Test"; //string you want to find
            object oTrue = true;
            object oFalse = false;
            object oFindStop = Microsoft.Office.Interop.Word.WdFindWrap.wdFindStop;
            if (range.Find.Execute(ref findText, ref oTrue, ref oFalse, ref oTrue,
                 ref oFalse, ref oFalse, ref oTrue, ref oFindStop, ref oFalse))
            {
                range.Select();
                Globals.ThisAddIn.Application.Selection.Range.HighlightColorIndex = WdColorIndex.wdDarkYellow; //highlight the string which was found
            }
        }

您可以参考以下链接获取有关Range.Find的更多信息。

You could refer the link below for more information about Range.Find.

#如何:以编程方式设置Word中的搜索选项

https://msdn.microsoft.com/en-us/library/tf2wdd02.aspx?f=255&MSPPError=-2147217396

# How to: Programmatically Set Search Options in Word
https://msdn.microsoft.com/en-us/library/tf2wdd02.aspx?f=255&MSPPError=-2147217396

最好的问候,

Best Regards,

Edward