天天看点

word2007插件开发经验备忘3--如何操作文本字体

文本设置就是设置font的属性,设置为word.font的类

但是有个问题,如何把一列文本中的特定字设置字体呢?

word2007插件开发经验备忘3--如何操作文本字体
word2007插件开发经验备忘3--如何操作文本字体

public void addtotable(word.table table, int row, string docname)

{

table.cell(row, 2).range.text = this.tdicatelog1;

table.cell(row, 3).range.text = this.tdisubcatelog1;

#region add description table.cell(row, 4)

word.font normalfont = table.cell(row, 3).range.font;

string description = "title:\n" + docname + ":" + this.tdititle1 + "\nsection:\n" + this.tdisection1 + "\npage:\n" + this.tdipage1 + "\ntechnical document content:\n"

+ this.tdicontent1 + "\ntechnical document issue:\n" + this.tdiissue1 + "\nrecommended change:\n" + this.tdicommendchange1 + "\nreproduction steps:\n";

table.cell(row, 4).range.text = description;

table.cell(row, 4).range.select();

word.selection seletiontext = table.application.selection;

word.find find = seletiontext.find;

object findtext = docname;

object matchcase = false;

object matchwholeword = true;

object matchwildcards = false;

object matchsoundslike = false;

object matchallwordforms = false;

object forward = true;

object wrap = word.wdfindwrap.wdfindstop;

object find_format = false;

object replacewith = docname;

object replace = word.wdreplace.wdreplacenone;

object matchkashida = false;

object matchdiacritics = false;

object matchalefhamza = false;

object matchcontrol = false;

if (find.execute(ref findtext, ref matchcase, ref matchwholeword, ref matchwildcards, ref matchsoundslike, ref matchallwordforms, ref forward, ref wrap, ref find_format, ref replacewith, ref replace,

ref matchkashida, ref matchdiacritics, ref matchalefhamza, ref matchcontrol))

seletiontext.font = normalfont;

}

//change teh tdititile;

seletiontext = table.application.selection;

findtext = ":" + this.tdititle1;

//change teh tdisection;

findtext = tdisection1;

//change teh tdipage;

findtext = this.tdipage1;

//change teh tdicontent;

findtext = this.tdicontent1;

//change teh tdiissue;

findtext = this.tdiissue1;

//change teh tdicommentchange;

findtext = this.tdicommendchange;

#endregion

table.cell(row, 5).range.text = "spec review";

table.cell(row, 6).range.text = "bug id \nto be reivewed\n";

table.cell(row, 7).range.text = "3";

table.cell(row, 8).range.text = "3";

word2007插件开发经验备忘3--如何操作文本字体

就是使用find.execute()这个函数,相当于查找+选中,于是问题就解决了.....