有没有办法用C#实现把WORD文档中某些已知字符串变成红色或者是加下划线。起到打记的作用,
谢谢各位拉

解决方案 »

  1.   

    有办法,我可以给你写一个Dll类。你直接用即可
      

  2.   

    //引用 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();
      }
      

  3.   

    用tlbimp MSWORD9.OLB /out:Microsoft.Office.Word.dll生成一个dll
      

  4.   

    用tlbimp MSWORD9.OLB /out:Microsoft.Office.Word.dll生成一个dll
    什么意思??