有没有办法用C#实现把WORD文档中某些已知字符串变成红色或者是加下划线 有没有办法用C#实现把WORD文档中某些已知字符串变成红色或者是加下划线。起到打记的作用,谢谢各位拉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有办法,我可以给你写一个Dll类。你直接用即可 //引用 Microsoft Word 9.0 Object Library Word.Application wApp = new Word.ApplicationClass(); wApp.Visible = true; object WordFile = @"E:\Work\Tools\WindowsApplication1\bin\Debug\test.doc"; object ConfirmConversions = false; object ReadOnly = false; object AddToRecentFiles = false; object PasswordDocument = ""; object PasswordTemplate = ""; object Revert = false; object WritePasswordDocument = ""; object WritePasswordTemplate = ""; object Format = Word.WdOpenFormat.wdOpenFormatAuto; object Encoding = Missing.Value; object Visible = true; Word.Document wDoc = wApp.Documents.Open(ref WordFile, ref ConfirmConversions, ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, ref Revert, ref WritePasswordDocument, ref WritePasswordTemplate, ref Format, ref Encoding, ref Visible); Word.Find find = wApp.Selection.Find; find.ClearFormatting(); object FindText = "要标识的词"; 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 = ""; object Replace = Word.WdReplace.wdReplaceNone; object MatchKashida = false; object MatchDiacritics = false; object MatchAlefHamza = false; object MatchControl = false; while(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)) { wApp.Selection.Font.Color = Word.WdColor.wdColorRed; find.ClearFormatting(); } 用tlbimp MSWORD9.OLB /out:Microsoft.Office.Word.dll生成一个dll 用tlbimp MSWORD9.OLB /out:Microsoft.Office.Word.dll生成一个dll什么意思?? c# winform 网络软件是怎么连接数据库的 如何实现从TreeView控件拖拽数据到PictureBox中显示? AxWebBrowser浏览网页,怎么获取网页中文本框的值 请进教C#中的索引与集合中的迭代器相关 c# 资源文件的问题 一个简单的问题,请看正文! 如何让自己编写的类绑定到DataGrid时,具有AddNew功能 ? 求助“吞食鱼”的程序代码??(C#) 企业级即时消息系统结构分析探讨 暂停几秒后,执行下一过程 ++++++++++++++++++++++++++如何类型转换成Bool型??++++++++++ 请教关于如何判断某个进程是否在运行?
Word.Application wApp = new Word.ApplicationClass();
wApp.Visible = true; object WordFile = @"E:\Work\Tools\WindowsApplication1\bin\Debug\test.doc";
object ConfirmConversions = false;
object ReadOnly = false;
object AddToRecentFiles = false;
object PasswordDocument = "";
object PasswordTemplate = "";
object Revert = false;
object WritePasswordDocument = "";
object WritePasswordTemplate = "";
object Format = Word.WdOpenFormat.wdOpenFormatAuto;
object Encoding = Missing.Value;
object Visible = true; Word.Document wDoc = wApp.Documents.Open(ref WordFile, ref ConfirmConversions, ref ReadOnly,
ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, ref Revert,
ref WritePasswordDocument, ref WritePasswordTemplate, ref Format, ref Encoding, ref Visible);
Word.Find find = wApp.Selection.Find;
find.ClearFormatting(); object FindText = "要标识的词";
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 = "";
object Replace = Word.WdReplace.wdReplaceNone;
object MatchKashida = false;
object MatchDiacritics = false;
object MatchAlefHamza = false;
object MatchControl = false;
while(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))
{
wApp.Selection.Font.Color = Word.WdColor.wdColorRed;
find.ClearFormatting();
}
什么意思??