vba Word 2007中如何直接跳转到当前表格单元格的最后一行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12670339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to jump directly to the last line of the current table cell in Word 2007?
提问by MostlyHarmless
I have a large Table in MS Word 2007 (spanning several pages) and each row contains a lot of text.
我在 MS Word 2007 中有一个大表(跨越几页),每一行都包含大量文本。
Is there a keyboard shortcut in Word 2007 to directly jump to the last line of the current table cell to add text at the "bottom" of the cell?
Word 2007 有没有快捷键可以直接跳转到当前表格单元格的最后一行,在单元格的“底部”添加文字?
If there is not, how could I do that with VBA?
如果没有,我怎么能用 VBA 做到这一点?
回答by Olle Sj?gren
Use Alt+PgDownto go to the last row in the current table (in the same column).
使用Alt+PgDown转到当前表中的最后一行(在同一列中)。
The equivalent in VBA:
VBA 中的等效项:
Selection.EndKey Unit:=wdColumn
EDIT
编辑
(Updated after new information in the question)
(在问题中的新信息后更新)
Sorry, I misunderstood. OK, then, try the following to find the end of the cell in VBA:
对不起,我误会了。好的,那么,尝试以下在VBA中找到单元格的结尾:
Selection.EndOf Unit:=wdCell
I don't know if it can be done with keyboard shortcuts, maybe someone else knows?
不知道能不能用键盘快捷键来完成,也许其他人知道?
回答by Exertus
A combination of keys are possible but I'm not sure it will work in every case:
组合键是可能的,但我不确定它是否适用于所有情况:
- Tab(to jump to the next cell), Left, Left,
- Or Tab, Shift+Tab(current cell selected), Right(end of selection = end of current cell)
- Tab(跳转到下一个单元), ,,LeftLeft
- 或Tab, Shift+ Tab(当前选中的单元格), Right(选中结束 = 当前单元格结束)
回答by C J
Wouldn't the best way in VBA be to just refer to the last row?
VBA 中最好的方法不是只引用最后一行吗?
table.Cell(table.rows.count, yourColumnNumberToUpdate).Range.Text = table.Cell(table.rows.count, yourColumnNumberToUpdate).Range.Text + "What ever you want to add to the bottom of the cell"
Of course if there was text already in the cell you would want to add a carriage return so the added text was at the bottom of the cell.
当然,如果单元格中已经有文本,您需要添加一个回车符,以便添加的文本位于单元格的底部。