如何用poi打开word文档的特定段落?

发布于 2024-07-28 23:48:39 字数 207 浏览 6 评论 0原文

要求是这样的...

我们正在阅读Word文档并从该文档中获取所有注释,并且我们正在将该文档发送给用户,当用户打开该文档时,该文档应该以某些特定页面特定段落打开。 (我们可以提供特定的页面、段落位置,我可以提供 org.apache.poi.hwpf.usermodel.Range 对象。)

请提供一些示例代码来执行此功能...

感谢您的帮助...

Requirement is this ...

We are reading word document and getting all annotation from that document, and we are sending this document to user, when user open the document that time document should open with some specific page specific paragraph. ( That specific page, paragraph location we can give it, I can give the org.apache.poi.hwpf.usermodel.Range object. )

Please provide some example code to do this functionality ...

Appreciate you help ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑咖 2024-08-04 23:48:39

使用 Apache POI 无法实现这一点。

我能想到的让 Microsoft Word 在打开文档时滚动到特定范围的唯一方法是包含一个选择范围的 AutoOpen VBA 宏。

例如,要选择第 9 段,您必须包含以下 VBA 代码(不言而喻,这仅在启用宏的情况下才有效):

Public Sub AutoOpen()

    ActiveDocument.Paragraphs(9).Range.Select

End Sub

There is no way this can be achieved using Apache POI.

The only way I can think of to have Microsoft Word scroll to a specific range when a document is opened would be to include an AutoOpen VBA macro that selects the range.

For example, to make the 9th paragraph be selected you would have to include the following VBA code (it goes without saying that this only works if macros are enabled):

Public Sub AutoOpen()

    ActiveDocument.Paragraphs(9).Range.Select

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文