欢迎来到科站长!

office激活

当前位置: 主页 > 网站运营 > office激活

word怎么用VBA命令完成保存退出

时间:2025-04-15 15:18:08|栏目:office激活|点击:

1、打开Word文件的 VBA编辑器,快捷键 Alt+F11,右击【ThisDocument】-》 【插入模块】;
2、双击刚才插入的【模块1】,添加如下代码:
Private Function SaveAsFile(ByVal fileFormat As String)

Dim strDocName As String
Dim intPos As Integer
'Find position of extension in filename
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
'If the document has not yet been saved
'Ask the user to provide a filename
strDocName = InputBox("Please enter the name of your document.")
Else
'Strip off extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & fileFormat
End If
'Save file with new extension
ActiveDocument.SaveAs fileName:=strDocName, fileFormat:=wdFormatText
'Close active document
ActiveDocument.Close SaveChanges:=wdSaveChanges, OriginalFormat:=wdOriginalDocumentFormat

End Function
3、保存代码及文件,且关闭word并重新打开,重新打开点击【选项】-》 【启用此内容】


上一篇:WORD文档怎么从第二节页脚开始插入页码

栏    目:office激活

下一篇:word文档里的工具栏窗口怎么打开

本文标题:word怎么用VBA命令完成保存退出

本文地址:https://www.fushidao.cc/wangzhanyunying/5441.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 科站长 版权所有冀ICP备14023439号