Range.Text不包括非断开连字符 [英] Range.Text not including non-breaking hyphens

查看:116
本文介绍了Range.Text不包括非断开连字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个涉及逐段阅读Word文档中的文本的应用程序。我们最近发现了一个问题,即从文档中读取的文本中不包含非断开连字符。这会影响我们申请的其他部分

I am working on an application that involves reading the text in a Word document paragraph by paragraph. We have recently discovered an issue where non-breaking hyphens are not being included in the text that is read from the document. This is affecting other parts of our application.

通过调试,我发现当我读到Paragraph.Range.Text时,不会出现非断开连字符。因此,文档文本是"abc-123"。其中 - 是一个不间断的连字符,在Paragraph.Range.Text中显示为"abc123"。
在尝试获取Paragraph.Range.Text之前,我尝试将TextRetrievalMode.IncludeFieldCodes设置为true,将TextRetrievalMode.IncludeHiddenText设置为true,我仍然得到相同的结果。我是否必须做一些特定的事情来使我的Range.Text中出现不间断的
连字符?

Through debugging, what I have found is that when I read the Paragraph.Range.Text, the non-breaking hyphens do not appear. So document text that was "abc-123" where the - is a non-breaking hyphen, appears in Paragraph.Range.Text as "abc123". I have tried setting the TextRetrievalMode.IncludeFieldCodes to true and the TextRetrievalMode.IncludeHiddenText to true before attempting to get the Paragraph.Range.Text and I still get the same result. Do I have to do something specific to get the non-breaking hyphens to appear in my Range.Text?

示例代码阅读包含abc-123的文件,其中 - 是一个不间断的连字符

Sample code reading document containing abc-123 where - is a non-breaking hyphen

(应用程序在文件的前面定义)

(application is defined earlier in the file)

public void TestFunction()
{
    var paragraph =     
        application.ActiveDocument.Paragraphs.First;
    var text = paragraph.Range.Text; //"abc123\r"
}

示例代码阅读文档包含abc-123,其中 - 是一个不间断的连字符

Sample code reading document containing abc-123 where - is a non-breaking hyphen

(应用程序已定义在文件的前面)

(application is defined earlier in the file)

public void TestFunction()
{
    var paragraph = 
        application.ActiveDocument.Paragraphs.First;
    paragraph.Range.TextRetrievalMode.IncludeFieldCodes = 
        true;
    paragraph.Range.TextRetrievalMode.IncludeHiddenText = 
        true;
    var text = paragraph.Range.Text; //"abc123\r"
}

推荐答案

为了确保我们都在同一页面上:

To make sure we're all on the same page:

1。 Word的版本?

1. Version of Word?

1。什么是非破坏连字符的ANSI代码?

1. What's the ANSI code of the non-breaking hyphen?


这篇关于Range.Text不包括非断开连字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆