word2007插件开发经验备忘3--如何操作文本字体
2010-10-29 13:55
441 查看
文本设置就是设置Font的属性,设置为Word.Font的类
但是有个问题,如何把一列文本中的特定字设置字体呢?
代码
就是使用find.execute()这个函数,相当于查找+选中,于是问题就解决了.....
但是有个问题,如何把一列文本中的特定字设置字体呢?
代码
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; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = ":" + this.TDITitle1; 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 TDISection; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = TDISection1; 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 TDIPage; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = this.TDIPage1; 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 TDIContent; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = this.TDIContent1; 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 TDIIssue; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = this.TDIIssue1; 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 TDICommentChange; table.Cell(row, 4).Range.Select(); seletionText = table.Application.Selection; FindText = this.TDICommendChange; 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; } #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"; }
就是使用find.execute()这个函数,相当于查找+选中,于是问题就解决了.....
相关文章推荐
- word2007插件开发经验备忘3--如何操作文本字体
- word2007插件开发经验备忘2--如何操作word
- word2007插件开发经验备忘2--如何操作word
- word2007插件开发经验备忘1--如何开发word插件
- word2007插件开发经验备忘1--如何开发word插件
- discuz 插件开发经验之如何运用 C::t 方法
- iOS开发经验技巧之iOS上如何让按钮文本左对齐问题
- 快速Eclipse开发经验--文本替换和操作界面
- 快速Eclipse开发经验--文本替换和操作界面
- [展示] 插件开发经验之如何运用 C::t 方法
- 基于Metronic的Bootstrap开发框架经验总结(17)-- 使用 summernote插件实现HTML文档的编辑和图片插入操作
- [置顶]团队开发经验:如何带领一个项目团队并做好项目总结
- php微信开发备忘-接收处理文本消息
- 浅谈C/C++ 开发Excel插件之操作excel
- POI对EXCEL的操作【重点:如何设置CELL格式为文本格式】
- 团队开发经验:如何带领一个项目团队并做好项目总结 !!
- Android开发之不同字体、不同颜色的文本、URL
- SonarQube插件开发自定义规则(2)常用api-扫描java文本内容
- 开发者是如何提升技能水平的 发表于1小时前| 770次阅读| 来源SquareSpace| 1 条评论| 作者Denis Gobo 开源程序员博客代码编程经验分享 摘要:作为一个技术开发人员,不断的学
- 图形的绘制,如何使用自定义画笔(颜色,线宽,线形)。如何为程序中添加选项菜单和选项设置对话框,如何使用标准颜色对话框,如何使用字体对话框,在选项对话框中实现预览功能。实现选项对话框和窗口类中的数据交换。如何改变对话框和控件的背景色,如何改变控件的文本颜色,