2014-02-05 36 views
0

我正在使用Microsoft.Office.Interop.Word读取Word文档中的文本并返回文件中的每个单词。在Word文档中,有一个电子邮件地址,不幸的是我没有收到完整的电子邮件地址。例如:电子邮件地址是[email protected],但我得到(1)abc(2)@(3)xyz(4)。 (5)的COM。Microsoft.Office.Interop.Word无法返回完整的电子邮件地址

如何使用的Microsoft.Office.Interop.Word得到完整的电子邮件地址?谢谢。

代码:

Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application(); 
       Document document = application.Documents.Open(txtUploadedPathToken.Text); 


       // Loop through all words in the document. 
       int count = document.Words.Count; 


       foreach (Microsoft.Office.Interop.Word.Range range in document.Words) 
       { 

        string text = range.Text; 
        tableLayoutPanel2.Controls.Add(new Label() { Text = text, Anchor = AnchorStyles.Left, AutoSize = true }); 


       } 
+1

向我们展示你的代码。 – SLaks

+0

@SLaks,我已更新我的问题,包括代码 – user3248886

回答

0

我想我已经找到了解决办法。这是通过使用Content.Text和.Split作为下面的代码。

string doctexts = document.Content.Text; 

string[] docwords = doctexts.Split(' '); 
相关问题