Word中如何获取表格行高
我到处寻找并尝试了各种方法。一直认为这是不可能完成的。所以我要在这里尝试一下,看看其他人是否有运气。
当行的 HeightRule
设置为 wdRowHeightAuto
时,有什么方法可以获取 Word 中表格行的高度吗?
或者,如果有一种方法可以获取单元格的高度,我会接受它作为解决方案,因为您可以通过查找行的最大单元格来计算行的高度。
I've looked all over the place and tried various things. It's been assumed that it can't be done. So I'm going to try here and see if anybody else has had any luck.
Is there any way to get the height of a table row in Word when the row's HeightRule
is set to wdRowHeightAuto
?
Alternatively, if there's a way to get the cell's height instead, I'll accept that as a solution since you can calculate the row's height by finding the row's biggest cell.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以使用 Range.Information() 找到行高。以下代码片段不适用于表格中的最后一行或页面上的最后一行。
这通过计算所选行与下一行之间的位置差异来返回行的高度(以磅为单位)。
我有一个在所有情况下都有效的例程,并返回单元格中第二行和后续行的高度(以点为单位),即单行单元格返回 0。(我在应用程序中使用它,将某些单元格中的字体大小减小到将文本放在一行上。)
It's possible to find the row height with Range.Information(). The following snippet doesn't work for the last row in a table or the last row on a page
This returns the height of the row in points by calculating the difference in position between the selected row and the following one.
I have a routine which works in all cases and returns the height in points of the second and subsequent lines in a cell, i.e. a single-line cell returns 0. (I use this in an application which reduces the font size in certain cells to fit the text on one line.)
作弊怎么办?
How about cheating?
我尝试了上面的操作,发现更改 HeightRule 会更改行的高度,鉴于我试图“冻结”事先出现在表格中的高度,这使得上面的内容毫无意义。
对于空行或包含以一致段落格式添加字体大小的单个展开文本段落的行,para before 和 after 可以按如下方式工作:
I tried the above and found that changing the HeightRule changes the height of the row, which given I am trying to "freeze" the height on what appears in my table beforehand, makes nonsense of the above.
For rows which are empty or contain a single paragraph of unwrapped text in a consistent paragraph format adding up the font size, para before and after can work as follows: