简体   繁体   English

如何确定 MS Word 中 VBA 字段的页码?

[英]How can I determine the page number of a field in MS Word with VBA?

I am using the QR-Code DISPLAYBARCODE field.我正在使用二维码 DISPLAYBARCODE 字段。 I am updating all DISPLAYBARCODE with some information like date and time, additionaly I want to add the page number on which the DISPLAYBARCODE field is.我正在使用日期和时间等信息更新所有 DISPLAYBARCODE,另外我想添加 DISPLAYBARCODE 字段所在的页码。

For tables I would use the range field but this is not available for fields.对于表格,我会使用范围字段,但这不适用于字段。

Is there a way how to do that?有办法吗?

If you want the page number to display as part of the QR Code, you could embed a page field in the text of the code.如果您希望页码显示为 QR 码的一部分,您可以在代码文本中嵌入页码字段。 Something like:就像是:

  • { DisplayBarCode "{ Date } { Time } Page { Page }" QR \s 100 \r 0 \q 3 } { DisplayBarCode "{ 日期 } { 时间 } 页 { 页 }" QR \s 100 \r 0 \q 3 }

Note the quotation marks.注意引号。 They are necessary.他们是必要的。

The DATE and TIME fields are the date and time when the document is printed or those fields are updated. DATE 和 TIME 字段是打印文档或更新这些字段的日期和时间。 They are not fixed timestamps.它们不是固定的时间戳。


I am working on the code for you to enter a field like the one shown.我正在为您编写代码以输入如图所示的字段。

  • Is that what you want?那是你要的吗?
  • Do you want to have the page, date, and time appear inside the DisplayBarCode field so that they show up when the bar code is read?您想让页面、日期和时间出现在 DisplayBarCode 字段中,以便在读取条形码时显示它们吗?
  • Do you instead of the current date and time want a time stamp for when the code is run?您是否想要代码运行时的时间戳而不是当前日期和时间?
  • What else goes in the field?该领域还有什么? The current content?目前的内容? Before or after the date, time and page?在日期、时间和页面之前还是之后?

Take a look at the second answer in this thread (from WillWillPower): Setting up a nested field in Word using VBA查看此线程中的第二个答案(来自 WillWillPower): Setting up a nested field in Word using VBA

It uses the range of the field code.

暂无
暂无

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

相关问题 如何确定MS Word宏中表格的页码? - How can I determine the page number of a table in MS Word Macro? 在 MS Word 中,如何将包含“$1540.38-”的 Set Field 转换为负数,我可以求和 - In MS Word how do I convert a Set Field containing “$1540.38-” to a negitive number I can sum 如何在 MS Word 中使用 VBA 确定表格单元格中的段落是编号还是项目符号? - How, using VBA in MS Word, do I determine if paragraphs in table cells are numbered or bulleted? 如何使用 VBA 在 Word 模板的页脚中插入页码字段逻辑? - How can I insert page numbering field logic into a footer on my Word template using VBA? 我如何重写以下MS Word VBA宏以与Word 2007/2010/2013兼容 - How can I rewrite the following MS Word VBA macro to be compatible with Word 2007/2010/2013 通过Word中的VBA添加注释包括页码字段 - Adding comments through VBA in Word includes page number field 如何使用 Excel VBA 引用 MS Word 目录页码? - How to reference MS Word table of contents page numbers with Excel VBA? 如何使用vba脚本检查MS Word页面页边距? - how to check MS Word page margins using vba script? MS Word / VBA-如何遍历文档并查找2个字符串以删除它们之间的所有内容? - MS Word / VBA - how can I loop through the document and look for 2 strings to remove everything in between them? 如何使用 VBA 遍历 MS Word 中的每个字母? - How can I loop through every letter in MS Word using VBA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM