Microsoft.Office.Interop.Word无法返回完整的电子邮件地址

时间:2014-02-05 14:09:31

标签: c#

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

如何使用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 个答案:

答案 0 :(得分:0)

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

string doctexts = document.Content.Text;

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