单词,单词垂直位置的问题 [英] Word, problem with vertical position of words

查看:100
本文介绍了单词,单词垂直位置的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a function in c# that reads a word document by words. First it is placed on the page and then it goes through the words. The words are between columns. I need to know when a word is on the same line as the previous one or below the previous one.

执行 这个,我参考每个单词的垂直位置页面顶部。
在某些情况下, out "> 1 和word 2 有空格使word 2 进入下一个线。当我要求 单词 2 的垂直位置时,它返回相同的位置 as 单词 1 。我已经尝试打开互操作并在屏幕上显示页面,询问 垂直位置,它返回相同的位置,在屏幕上显示一个单词 低于另一个单词。

To dothis, I consult the vertical position of each word with respect to the top of the page. It turns out that in some cases, between word 1 and word 2 there are spaces that make word 2 go down to the next line. When I ask for the vertical position of the word 2, it returns the same position as the word 1. I have tried making the interop open and show the page on the screen to ask for the vertical position and it returns the same position, when it appears on the screen that one word is below the other.

页面上的Word循环:
foreach (Microsoft.Office.Interop.Word.Range word in MyRange.Words)

垂直
垂直 float = word.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage);

感谢 你的帮助。

Word loop on the page: foreach (Microsoft.Office.Interop.Word.Range word in MyRange.Words) Vertical vertical float = word.get_Information (Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage); Thanks for your help.

推荐答案

Hi zequion,

Hi zequion,

我无法重现您的问题。我创建了一个包含四列的word文档,如下所示。

I failed to reproduce your issue. I create a word document with four columns like below.

然后我尝试使用下面的代码返回"Word1"的垂直位置。和"Word2"。

Then I tried to use below code to return vertical position of "Word1" and "Word2".

float postion;
            foreach (Microsoft.Office.Interop.Word.Range word in MyRange.Words)
            {   
                if(word.Text.Trim()=="Word1"|| word.Text.Trim() == "Word2") { 
                postion= word.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage);
                Debug.Print(postion.ToString());
                }
            }

所有返回结果为72,然后我在"Word1"之后放置空格在第一列中制作"Word2"转到下一行。

All the return result is 72 and then I put space after "Word1" in first column to make "Word2" go to the next line.

 现在,返回结果是72 86.25 72 72 72 72 72 72.显然,86.25是"Word2"的垂直位置。在第一列。

 Right now, the return result is 72 86.25 72 72 72 72 72 72. Obviously, 86.25 is the Vertical position of the "Word2" in first column.

我误解了什么吗?您的文档中的情况如何?您可以分享一个简单的文档并告诉我们您的步骤,以便我们可以尝试重现您的问题吗?

Did I misunderstand anything? What's the situation in your document? Could you share a simply document and tell us your steps so we could try to reproduce your issue?

您可以通过OneDrive共享该文件并将此行放在此处。感谢您的理解。

You could share the file via OneDrive and the put the line here. Thanks for understanding.

最好的问候,

Terry


这篇关于单词,单词垂直位置的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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