例如一word文件如下:
hello使用程序获得出此word文件中的每个字母的颜色,并输出。
h 默认
e 红色
如此使用COM,看了Application,Document等等等等
网上也找了不少,始终没有思路
请指点指点,谢谢

解决方案 »

  1.   

    楼主,在word里面有一个查找取代的功能,这个功能可以查找到指定颜色的文字,如果你把这个查找的原理搞懂了应该就可以遍历出来了。
    你去看下这个功能:http://www.it.com.cn/f/edu/0811/19/693143.htm
      

  2.   

    楼主,用VBA吧,很容易搞定,foreach(pgf) if words.color=? then...
      

  3.   

    wdoc.Content.Font.Color 
    只能这么离颜色近点。
    文本没那个属性,只能取到文本内容关注!
      

  4.   


                    object oMissing = System.Reflection.Missing.Value;
                    Microsoft.Office.Interop.Word._Application oWord;
                    Microsoft.Office.Interop.Word._Document oDoc;
                    oWord = new Microsoft.Office.Interop.Word.Application();
                    oWord.Visible = false;
                    object fileName = System.IO.Directory.GetCurrentDirectory() + "\\test.doc";
                    oDoc = oWord.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);                for (int i = 0; i < oDoc.Content.Text.Length; i++)
                    {
                        try
                        {
                            if (oDoc.Content.Text.ToString().Trim().Substring(i, 1) != " ")
                            {
                                oWord.Selection.MoveRight(ref oMissing, ref oMissing, ref oMissing);
                                this.richTextBox1.Text += oDoc.Content.Text.ToString().Substring(i, 1) + ":" + oWord.Selection.Font.ColorIndex.ToString() + "\n\r";
                            } 
                        }
                        catch
                        {
     
                        }
                    }                if (oDoc != null)
                        oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                    if (oWord != null)
                        oWord.Quit(ref oMissing, ref oMissing, ref oMissing);