作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含2页的Word文档,并且已插入表,该表从第一页开始,一直持续到第二页的中间(文档中仅存在一个表)。
在Delphi(XE7)和OLE自动化(变体和Office 2013)中,如何在表格后移动光标?
(在Word文档文件中,我已经反复按Enter键)
为此,这些代码将不起作用:
Selection.GoTo(wdGoToItem.wdGoToPage, wdGoToDirection.wdGoToLast);
Selection.EndKey(wdStory, EmptyParam);
lvParag := ActiveDocument.Paragraphs.First;
Result := Range.Sentences.First.End - 1;
最佳答案
有多种解决方法。我使用的是获取表的范围,然后折叠范围。这样的东西(VBA,但“翻译”它应该没有任何困难):
Dim tbl as Word.Table, rng as Word.Range
Set tbl = ActiveDocument.Tables(1)
Set rng = tbl.Range
rng.Collapse wdCollapseEnd 'Word.WdCollapseDirection.wdCollapseEnd
'If you need to show the user the Selection
rng.Select()
'Otherwise, continue to work with the Range object, adding text, for example:
rng.Text = "text following the table"
'and formatting it
rng.Style = "style name"
关于delphi - 如何在Word应用程序中将光标移动到表格末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34393260/
我是一名优秀的程序员,十分优秀!