- ·上一篇:word如何做电子画册,如何做,画册,电子
- ·下一篇:电脑word如何用数学符号,符号,数学,电脑
如何在word名字显示日期,名字,日期,显示
1.如何实现WORD保存 文件名有日期
1、首先需要确保Word的宏安全性设置至少为“中”(工具-宏-安全性-中)。
2、在Word里面新建一个空白文档,给它随便取个名字(比如“我的日志”)保存一下——这个文档就是你以后日志文档的开端了!(注意,如果你用的是Word 2007的话,需要保存为启用宏的文档*.docm)3、键入ALT+F11打开VBA编辑窗口,键入CTRL+R激活左边的“工程 – Project”面板;4、双击工程面板中的“Project (我的日志)\Microsoft Word 对象\ThisDocument”打开代码窗口;粘贴如下代码进去:Option ExplicitDim oLogFileCreator As LogFileCreatorPrivate Sub Document_Open() On Error Resume Next Set oLogFileCreator = New LogFileCreator Set oLogFileCreator.WordApplication = ApplicationEnd SubPrivate Sub Document_Close() On Error Resume Next Set oLogFileCreator.WordApplication = Nothing Set oLogFileCreator = NothingEnd Sub5、选择菜单“插入-类模块”,然后在工程面板里双击这个刚生成的“Project (我的日志)\类模块\类1”,粘贴如下代码进去:Option ExplicitPublic WithEvents WordApplication As Word.Application' 根据需要修改下面引号中的内容作为你日子文件的默认前缀Private Const c_strFileNamePrefix = "我的日志_"Private Sub WordApplication_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean) On Error Resume Next Dim fso As Object Dim strOldName As String, strNewName As String Set fso = CreateObject("Scripting.FileSystemObject") strOldName = ActiveDocument.FullName strNewName = fso.BuildPath(fso.GetParentFolderName(strOldName), Format(Now, c_strFileNamePrefix & "yyyy-mm-dd.") & fso.GetExtensionName(strOldName)) If UCase(strNewName) <> UCase(strOldName) Then ActiveDocument.SaveAs strNewName fso.DeleteFile strOldName Cancel = True End If Set fso = NothingEnd Sub6、可以根据需要修改代码中的日志文件名前缀。默认的日志文件名是类似 “我的日志_2009-09-12”这样的形式。
7、键入F4打开属性面板,在里面把“(名称)”从“类1”改为“LogFileCreator”。8、键入ALT+Q关闭VBA编辑窗口返回Word文档窗口,保存,关闭。
9、再次重新打开这个文档,如果Word提示是否启用宏,选择启用。10、现在你的这个自动按日期保存的日志就可以正常运作了。
每次你做完修改后,只要你一保存,它就会根据今天的日期自动把文档保存成类似这样的形式“我的日志_2009-09-12”(前缀“我的日志”可以在上面代码中修改)。
2.如何在WORD文件名后面自动添加时间?
WORD文件名后面自动添加时间方法如下:(1)ALT+F11,复制以下宏:Sub Macro1()Dim myfilename As Stringmyfilename = Format(Date, "yyyy/m/d ", vbSunday, vbUseSystem)myfilename = myfilename + ".doc" "C:\"ActiveDocument.SaveAs filename:=myfilename, FileFormat:=wdFormatDocument, _LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _:=False, SaveFormsData:=False, SaveAsAOCELetter:= _FalseEnd Sub(2)ALT+F8保存,运行MACRO1宏即可。
Microsoft Word是微软公司的一个文字处理器应用程序。它最初是由Richard Brodie为了运行DOS的IBM计算机而在1983年编写的。
随后的版本可运行于Apple Macintosh (1984年), SCO UNIX,和Microsoft Windows (1989年),并成为了Microsoft Office的一部分。用途:1、Word XP 基本文书处理技巧及认识萤幕工具。
2、快速键入中文标点符号。3、中文字符放大缩小、直式通告制作,中式公函。
4、各款中文繁/简字体及香港常用字库运用。5、行距、段落对齐、建立清单列、定位点设定 Word让文档编辑变得如此简单。
6、使用页头及页尾加入文件标题及页码。7、表格及多栏制作,以方便制作报价单,会议议程及工作时间表。
8、加插图片、图表、文字艺术师等中文桌面印刷以制作图文并茂的文件或公司通讯。9、不同资料大量合拼打印信件。
