在word文档中插入代码

You can easily add the current date and time to your Word documents, but what if you only want to add the month or month and year, but no date? It’s easy to manually add a custom date field and we’ll show you how.

您可以轻松地将当前日期和时间添加到Word文档中,但是如果您只想添加月份或月份和年份却不添加日期怎么办? 手动添加自定义日期字段很容易,我们将向您展示如何操作。

Adding a date field to your Word document using the Field command on the Insert tab adds the complete date, without an option to only add the month or year. However, you can manually create a date field with only the items you want in different formats. We’ll show you how to insert the month and year using a field code and how to change the format of the month and year using switches.

使用“插入”选项卡上的“字段”命令将日期字段添加到Word文档中会添加完整的日期,而不能选择仅添加月份或年份。 但是,您可以手动创建日期字段,仅包含所需格式不同的项目。 我们将向您展示如何使用域代码插入月份和年份,以及如何使用开关更改月份和年份的格式。

In our example, we’re creating a title page for our monthly TPS Report and want to include the current month and year. We can create this as a template that we can use each month to quickly create the cover page, or we can just use the same document each month and update the date field.

在我们的示例中,我们为每月的TPS报告创建标题页,并希望包含当前的月份和年份。 我们可以将其创建为模板 ,以便每个月使用它来快速创建封面,或者我们每个月都可以使用相同的文档并更新日期字段。

To add a custom date field to your document, press Ctrl+F9 to insert braces to contain the field. You must use Ctrl+F9 to insert the braces and NOT just type the braces using the keyboard.

要将自定义日期字段添加到文档中,请按Ctrl + F9插入大括号以包含该字段。 您必须使用Ctrl + F9插入大括号,而不仅仅是使用键盘输入大括号。

We’re going to add the month and year for our example, so type the following inside the braces.

我们将为示例添加月份和年份,因此在大括号内键入以下内容。

date \@ "MMMM YYYY"

The MMMM and YYYY are switches that tell Word what format to use for the month and year.

MMMM和YYYY是告诉Word在月份和年份中使用哪种格式的开关。

Click “Update”, or press F9 (with the cursor inside the field code or the field code selected), to update the field and display the month and year.

单击“更新”,或按F9(光标位于域代码或域代码内),以更新域并显示月份和年份。

The field code above inserts the full month and year. However, you can format the month and year differently by changing the switches. Here is a list of the switches you can use for the month and year and what they produce:

上面的域代码将插入完整的月份和年份。 但是,您可以通过更改开关来格式化月份和年份。 以下是可用于月份和年份的开关及其产生的清单:

  • M: Displays the month as a number without a leading zero (0) for single-digit months. For example, August is “8”.M:将月份显示为一个数字,其中不包含前导零(0)。 例如,八月是“ 8”。
  • MM: Displays the month as a number with a leading zero (0) for single-digit months. For example, August is “08”.MM:将月份显示为一个数字,其中前几位为零(0)。 例如,八月是“ 08”。
  • MMM: Displays the month as a three-letter abbreviation. For example, August is “Aug”.MMM:将月份显示为三个字母的缩写。 例如,八月是“八月”。
  • MMMM: Displays the full name of the month, e.g., “August”.MMMM:显示月份的全名,例如“ August”。
  • YY: Displays the year as two digits with a leading zero (0) for years 01 through 09. For example, 2016 is displayed as “16”, and 2009 is displayed as “09”.YY:在01到09年之间以两位数字显示前导零(0)。例如,2016显示为“ 16”,而2009显示为“ 09”。
  • YYYY: Displays the year as four digits, e.g., 2016.YYYY:将年份显示为四位数,例如2016。

To make changes to the field code, right-click in the field and select “Toggle Field Codes” from the popup menu.

要更改域代码,请右键单击该域,然后从弹出菜单中选择“切换域代码”。

You can also insert the month and date separately. This is useful if you want to use them in different places. For example, to insert just the current month, enter date \@MMMM in the braces (as shown below). Or, to insert just the current year, enter date \@YYYY . Note that when using only one switch (MMMM or YYYY), you don’t need quotes around the switch.

您也可以分别插入月份和日期。 如果要在不同的地方使用它们,这将很有用。 例如,要仅插入当前月份, date \@MMMM在大括号中输入date \@MMMM (如下所示)。 或者,仅输入当前年份,请输入date \@YYYY 。 请注意,仅使用一个开关(MMMM或YYYY)时,不需要在开关周围加上引号。

You can also type the date field code, such as date @\ “MMMM YYYY” , and then select the text and press Ctrl+F9 to add the braces around the text and convert it to a field code.

您也可以键入日期字段代码,例如date @\ “MMMM YYYY” ,然后选择文本,然后按Ctrl + F9在文本周围添加大括号并将其转换为字段代码。

To update all the fields in a document, press Ctrl+A to select the entire document (except for textboxes, headers, footers, footnotes, and endnotes). Then, press F9 to update the fields. To update fields in textboxes, headers, footers, footnotes, and endnotes, you must go into those parts of the document separately, select the fields, and then press F9 to update them.

要更新文档中的所有字段,请按Ctrl + A选择整个文档(文本框,页眉,页脚,脚注和尾注除外)。 然后,按F9更新字段。 要更新文本框,页眉,页脚,脚注和尾注中的字段,必须分别进入文档的那些部分,选择字段,然后按F9键来更新它们。

翻译自: https://www.howtogeek.com/267499/how-to-insert-the-current-month-and-year-in-a-word-document-that-automatically-updates/

在word文档中插入代码

在word文档中插入代码_如何在自动更新的Word文档中插入当前的月份和年份相关推荐

  1. idea修改代码后没有重新编译_SpringBoot中实现代码修改之后的自动更新与热加载...

    在实际的开发过程中,我们经常修改代码之后,手动的重启项目,查看修改效果.那么有没有一种方式能够快速的.自动的帮我们将修改代码自动更新,避免手动重启,从而提高开发效率呢?是有的,对于这个功能很多人对功能 ...

  2. word中高效实现参考文献标注功能--自动更新--以word 2016为例

    word小白一个,平常都是用本办法解决的,写这篇文档的目的纯粹是为了以后方便自己查阅.我这里用的是word2016版本 灵活创建参考文献 首先光标选中要插入参考文献的地方,选中工具栏的引用,如图所示 ...

  3. Idea一键自动导包设置--导入类中所有包?教你自动更新类中包含的包

    在日常的拷贝复用代码中,导包的重复性工作非常繁琐,在这里分享一个idea设置. 动态效果演示: Idea一键自动导包设置--导入类中所有包?教你自动更新类中包含的包 操作步骤: File-->S ...

  4. xml文档包含html代码_为什么文档很重要,以及为什么应将其包含在代码中

    xml文档包含html代码 There are a plethora of acronyms when it comes to software development. KISS, DRY, SOL ...

  5. word 插入代码_突破Word页码困境,这招简单又实用的自动更新法,90%的人还不会!...

    微信扫码观看全套Excel.Word.PPT视频 在工作和学习中,常会遇到这样的情况,对于一篇既含有封面,又含有目录的文档,要求对它的页码进行如下设置:在文档底部靠右位置插入页码,页码形式为" ...

  6. markdown中引用代码_如何在Markdown中引用您JavaScript源代码

    markdown中引用代码 您是否撰写有关Javascript和Typescript的技术文章? (Do you write technical articles about Javascript a ...

  7. 表格序号_让Excel表格中的序号自动更新,再也不怕删除、插入行了

    以前小编发布过一篇<Excel自动生成序号的三种方法,省去一个一个录入的麻烦>,有粉丝问到:表格删除行或插入行后序号断了,能不能自动更新呢?今天小编就教大家自动更新序号的方法. 方法一:利 ...

  8. 怎么引入gallery中的代码_驻马店【脚本代码】

    驻马店[脚本代码],百变网络策划价格很低,在竞争激烈的网站建设行业,我们始终坚持以技术为核心,组建强大的技术开发团队,自主开发独立项目管理系统且安全稳定.简单易用:在业内具有强大的竞争力. 小白入门学 ...

  9. word转pdf图片模糊怎么办_迅捷PDF转换器如何将word转为长图?word转图片方法

    在日常工作中,我们基本都用word来编辑文档,编辑完成,如果将它保存为其他格式,那可能会出现跑版的情况.为了解决这一问题,我们可以用迅捷PDF转换器将word转长图,这样也方便在手机上阅读.只是很多人 ...

  10. 深度学习中交叉熵_深度计算机视觉,用于检测高熵合金中的钽和铌碎片

    深度学习中交叉熵 计算机视觉 (Computer Vision) Deep Computer Vision is capable of doing object detection and image ...

最新文章

  1. 5G NGC — 系统架构
  2. 智能可穿戴平台,你更看好谁?
  3. .NetCore 下开发独立的(RPL)含有界面的组件包 (四)授权过滤
  4. 32位mips运算器logisim_很多网友问32位低功耗MCU设计
  5. 兰州大学第一届『飞马杯』程序设计竞赛(同步赛),签到题ACFHJ
  6. NetDevOps常用数据库python实战-influxDB_grafana
  7. 楼板计算塑形弹性_阶梯教室板模板支架工程方案计算书(仅供参考)
  8. 原创力文档怎么免费下载_谁说下载文档需要下载券?老司机分享的良心工具,全网文档免费下...
  9. 英语在计算机上比汉语有优势吗,英语和汉语分别有什么优缺点?
  10. lol英雄联盟符文助手/一键应用符文易语言源码
  11. 常规创业公司股权分配参考
  12. 大尺寸背光检测~Dalsa线阵相机资料
  13. 如何在WORD中输入方框,并且在里面打勾?
  14. 获取jar包中的文件,及遍历jar包中的文件
  15. 完美解决迅雷极速版强制升级到迅雷X
  16. py读shp文件_入门-Python-读取Shapefile
  17. 从零开始使用 Mac 电脑之入门篇
  18. centos系统进行pppoe拨号
  19. Java后端阿里云短信平台发送短信
  20. 会动的古代名画,如画的江南古镇

热门文章

  1. 亲身经历,大龄程序员,为什么难找对象!
  2. 如何组织一个高效的开发团队?
  3. VUE学习笔记,最近12,12上班,没得空继续学习vue,先记录一下
  4. 【题解】P2627 [USACO11OPEN]Mowing the Lawn G
  5. 软件工程师欲发动DDoS攻击白宫网站 抗议特朗普就任总统
  6. 物质环境、符号还是认知模型?——谈韩礼德、马丁、范迪克的语境观
  7. h5画三角形_HTML5怎么画三角形?
  8. 如何制作一个餐厅下单和外卖二维码?
  9. 面试 11、知识拓展
  10. android 6.0 添加netcfg命令