如何chnage Word文件的选定单词的字体 [英] how to chnage font of a selected word of a Word File
本文介绍了如何chnage Word文件的选定单词的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的Word文件中搜索特定单词,并更改它的字体样式。但不知道怎么做,任何人都可以帮忙...
I want to search a specific word in my Word file, and change it's font style. But no idea how to do it, can anyone help...
推荐答案
检查一下,这里字体颜色改变了,你可以相应地改变字体样式:
C#搜索并替换Word中的字体颜色 [ ^ ]
也从中得到一些想法:
使用.NET在Microsoft Word中拼写文本 [ ^ ]
Check this, here font color is changed, you can change font style accordingly:
C# search and replace font color in Word[^]
Also get some idea from it:
Bolding Text in Microsoft Word using .NET[^]
Word.Range r = WordDoc.Range(ref onewstart, ref onewe);
//object rText = true;
find = r.Find;
find.Text = "Rest";
r.Find.Font.Underline = Word.WdUnderline.wdUnderlineSingle;
r.Find.Font.Bold = 1;
find.Execute(ref oMissing, ref matchword, ref matchwholeword, ref matchwildcards, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
if (find.Found)
{
Word.Table oTable;
Word.Range newrng;
int i = r.Start;
object o = r.Start;
object e = r.End;
newrng = WordDoc.Range(ref o, ref e);
string te = newrng.Text;
oTable = WordDoc.Tables.Add(newrng, 1, 1, ref oMissing, ref oMissing);
oTable.Columns.Item(1).Cells.Item(1).Range.Text = te;
oTable.Rows.Item(1).Range.Bold = 1;
oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
oTable.Cell(1, 1).Shading.BackgroundPatternColor = Word.WdColor.wdColorGray10;
// Word.Range newr;
object os = oTable.Range.End;
object oe = oTable.Range.End + 1;
WordDoc.Range(ref os, ref oe).Font.Size = 2;
}
像这样你可以改变Word的FOnt风格
like this u can able to change the FOnt Style of Word
这篇关于如何chnage Word文件的选定单词的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文