Upper Case words being converted to Lower Case when reading from a document

Hi,

When I read from a Word Document and store the value in a paragraph variable, even if the words are written in Upper Case, they appear as Lower Case. Any idea why this is happening.

This is the line of code I have that I have used

para = CType(srcNode, Paragraph)
strVariable = para.Range.Text.Trim

Hello
Thanks for your request.
Unfortunately I was unable to reproduce the problem on my side.
Please attach simple project example and the input document. I will try to simulate the situation.

Hi,

I have a word document that has the following lines

[[TEST FILE]]
BASE: ASSIGNED crm
As you can see, crm is in Lower case but when I see it in the document it is in Upper case.
And in the vb code that I have used to read the line is
For Each srcNode As Node In srcSection.Body
para = CType(srcNode, Paragraph)
strParagraphText = para.Range.Text.Trim
Next

So when the code reads

Hi
Thanks for additional information.
MS Word provides a formatting option to show text as uppercase, even when it is not. Aspose.Words also do it.
You apply this option by choosing the All Caps check box on the Font dialog box.
If you want to get all the text with capital letters, you have to go through all the text elements, convert them to uppercase and remove the option Font.AllCaps. Best for this using DocumentVisitor.

public class DocVisitor: DocumentVisitor
{
    public override VisitorAction VisitRun(Run run)
    {
        if (run.Font.AllCaps)
        {
            run.Text = run.Text.ToUpper();
            run.Font.AllCaps = false;
        }
        // Let the visitor continue visiting other nodes.
        return VisitorAction.Continue;
    }
}

If you still have questions, feel free to ask.

Hi

I do not want to format it to Upper case.

All I have to do is read it as it is in the Word Document.

But when I read the document CRM appears as Lower case.

Hi,
Thanks for additional information.
As I’ve said, for the text there is an opportunity to set the parameter Font.AllCaps = true;. Then, even the text of a writing with a lowercase letter will be seen as uppercase.
In your example the word “crm” is such a case. In MS Word right-click on the word “CRM”, then select the Font you’ll see that you have checked on the option All caps.
``
Try to disable this option and you will see the real state of the text as it was actually written.

The same thing is happening in your cycle when you read the text of the paragraph, the word “CRM” is actualy written in lowercase. But if you want what you read, match what you see is what you need to convert text as I suggested earlier.

Thank you so much for the immediate replies :slight_smile:

Hi,

Sorry for bothering you.

The solution that you gave would be useful if I have a small document.

However the documents that I use are over 6000 words.

Wont this solution be an extremely long procedure to check each and every word?

Is there any other way that this can be done?

Any help would be appreciated.

Hi
Thanks for your request. Actually, Aspose.Words uses DocumentVisitor to retrieve text from document. So, if you implement your own DocumentVisitor to get text from document, there will be no performance impact. For instance, you can implement DocumentVisitor like one provided in this article:
https://reference.aspose.com/words/net/aspose.words/documentvisitor/
Best regards,

Hi,

Thanks for that reply.
It really helped me solve the issue.
However I would like to know if there is any way to check for the ALL CAPS option in a string.

As in, if I say

Dim _StrText as String _strText=_para.Range.Text

is there anyway to check if the text has the ALL CAPS property checked.

Regards,
Adriel

Hi
Thanks for your request. Sure you can, please check Font.AllCaps property of Run nodes inside your paragraph:
https://reference.aspose.com/words/net/aspose.words/font/allcaps/
Best regards,