添加书签和交叉引用到Word文档(Add bookmarks and cross references to a Word document)

编程入门 行业动态 更新时间:2024-10-28 00:20:47
添加书签和交叉引用到Word文档(Add bookmarks and cross references to a Word document)

在Word 2010中,我想在文档中添加文本,为此文本添加书签,然后在文档的页眉和页脚中交叉引用此文本。

这可以录制还是我必须编码?

In Word 2010 I want to add text to a document, bookmark this text and then cross reference this text in the header and footer of the document.

Can this be recorded or will I have to code it?

最满意答案

对的,这是可能的。

是的,您可以在Word中录制 - 尽管有一些限制,因为在录制模式下您无法通过鼠标浏览文本; 生成的代码将是丑陋的,并且充满了“硬编码”,但会给你一个对象,方法和属性可能相关的印象。

如果你想要一个比一次性更可持续的解决方案,那么正确的编码肯定是要走的路。 您应该与以下人员交朋友以解决您的任务:

Selection对象及其方法,尤其是GoTo , Move及其变体 将光标扩展为标记文本的方法 使用各种Insert ...方法插入文本(例如Selection.InsertCrossReference ReferenceType:="Bookmark" ... ) 将书签添加到书签集合 了解如何操纵页眉和页脚

尝试一些编码,如果你遇到困难,可以回答更具体的问题。

Yes it is possible.

Yes you can record in Word - allthough with some limitations as you can't navigate thru your text by mouse when in recording mode; the generated code will be ugly and full of "hard coding" but will give you an impression which objects, methods and properties might be relevant..

If you want a solution that is a bit more sustainable than a one-off, proper coding surely is the way to go. You should make friends with the following in order to solve your task:

the Selection object and its methods, especially GoTo, Move and its variants the way to extend a cursor to mark text inserting text using various Insert... methods (e.g. Selection.InsertCrossReference ReferenceType:="Bookmark" ...) adding bookmarks to the Bookmarks collection understanding how to manipulate headers & footers

Try some coding and come back with more sopecific questions if you get stuck.

更多推荐

document,text,Word,电脑培训,计算机培训,IT培训"/> <meta name="descriptio

本文发布于:2023-07-30 22:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340284.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:书签   文档   Word   Add   document

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!