word2007插件开发经验备忘3--如何操作文本字体
2009-09-30 15:47
155 查看
文本设置就是设置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 方法
- 基于Metronic的Bootstrap开发框架经验总结(17)-- 使用 summernote插件实现HTML文档的编辑和图片插入操作
- 快速Eclipse开发经验--文本替换和操作界面
- 快速Eclipse开发经验--文本替换和操作界面
- [展示] 插件开发经验之如何运用 C::t 方法
- iOS开发经验技巧之iOS上如何让按钮文本左对齐问题
- C#开发网站如何提高性能--避免不必要的执行操作
- 如何设置WINCE系统字体、字号?如何设置自己开发的软件的字体、字号
- (转)基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用
- 团队开发经验:如何带领一个项目团队并做好项目总结 !!
- SonarQube插件开发自定义规则(2)常用api-扫描java文本内容
- 如何从零开始开发一款嵌入式产品(20年的嵌入式经验)
- 浏览器---Chrome前端开发必备插件,如何设置代理,react调试,定死https协议,sublime热更新,浏览器发请求post
- 人生经验——如何在三分钟内完成开发周期评估
- 苹果开发 笔记(60)文本字体、大小 、颜色、边框 设置