简体   繁体   English

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

[英]How to open word document at specific paragraph with poi?

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. 我们正在阅读Word文档并从该文档中获取所有注释,并且正在将该文档发送给用户,当用户打开文档时,该时间文档应以特定的页面特定段落打开。 ( That specific page, paragraph location we can give it, I can give the org.apache.poi.hwpf.usermodel.Range object. ) (我们可以给它特定的页面,段落位置,我可以给org.apache.poi.hwpf.usermodel.Range对象。)

Please provide some example code to do this functionality ... 请提供一些示例代码来实现此功能...

Appreciate you help ... 感谢您的帮助...

There is no way this can be achieved using Apache POI. 使用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. 我可以想到的是,在打开文档时使Microsoft Word滚动到特定范围的唯一方法是包括一个选择范围的AutoOpen VBA宏。

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): 例如,要选择第9段,您必须包含以下VBA代码(不言而喻,只有在启用宏的情况下,这才起作用):

Public Sub AutoOpen()

    ActiveDocument.Paragraphs(9).Range.Select

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用段落和运行的情况下更改特定表单元上的Apache POI Word文档中的字体颜色? - How to change font color in Apache POI word document on a specific table cell without using paragraph and run? 使用Apache POI在Word文档中添加不可见的段落 - add an invisible paragraph in a word document using Apache POI 使用Apache POI从Word文档中提取段落 - Extract Paragraph from Word Document Using Apache POI Apache poi:在段落中插入文本并查看 word 文档中的跟踪更改 - Apache poi: insert text in a paragraph and view track changes in a word document 如何将 Apache POI 中的段落部分加粗? (Word 文档) - How to partially bold a Paragraph in Apache POI? (Word Documents) 如何使用 Apache POI 在 Word 文档中插入图像? - How to insert a image in word document with Apache POI? 如何通过替换word文档中的字符串来插入段落 - How to insert a paragraph by replacing a string in word document 如何使用POI删除ms-word文档(docx)的一个特定页面? - How to delete one specific Page of a ms-word document (docx) with POI? 使用 apache poi 创建的 word 文档始终以兼容模式打开 - Created word document using apache poi always open in compatibility mode 使用apache poi将表格插入Word文档中的特定位置 - Insert table into a word document at a specific position using apache poi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM