2021-06-28 17:06:05
138
0
单层级 doc-docx
Sub ConvertBatchToDOCX()
Dim sSourcePath As String
Dim sTargetPath As String
Dim sDocName As String
Dim docCurDoc As Document
Dim sNewDocName As String
' Looking in this path
sSourcePath = "F:\wz\003-报告\后评价\2016问题建议后评价2-xls2\"
' Look for first DOC file
sDocName = Dir(sSourcePath & "*.doc")
Do While sDocName <> ""
' Repeat as long as there are source files
'Only work on files where right-most characters are ".doc"
If Right(sDocName, 4) = ".doc" Then
' Open file
Set docCurDoc = Documents.Open(FileName:=sSourcePath & sDocName)
sNewDocName = Replace(sDocName, ".doc", ".docx")
With docCurDoc
.SaveAs FileName:=sTargetPath & sNewDocName, _
FileFormat:=wdFormatDocumentDefault
.Close SaveChanges:=wdDoNotSaveChanges
End With
End If
' Get next source file name
sDocName = Dir
Loop
MsgBox "Finished"
End Sub
使用office宏命令 2级目录转换doc- docx
Sub ConvertBatchToDOCX()
Dim sSourcePath As String
Dim sDocName As String
Dim sDocNameOut As String
Dim docCurDoc As Document
Dim sNewDocName As String
' Looking in this path
sSourcePath = "F:\wz\003-报告\后评价\2015问题建议后评价1-xls2\"
Dim p2 As String
' Look for first DOC file
Set fso = CreateObject("scripting.filesystemobject") '创建FSO对象
Set folder = fso.getfolder(sSourcePath)
For Each sfd In folder.SubFolders
' MsgBox (sfd)
' FindFile sfd, FileName ' 循环查找
p2 = sfd.Path + "\"
sDocName = Dir(p2 & "*.doc")
Do While sDocName <> ""
' Repeat as long as there are source files
'Only work on files where right-most characters are ".doc"
If Right(sDocName, 4) = ".doc" And Left(sDocName, 5) = "4-最终版" Then
' Open file
Set docCurDoc = Documents.Open(FileName:=p2 & sDocName)
sNewDocName = Replace(sDocName, ".doc", ".docx")
With docCurDoc
.SaveAs FileName:=p2 & sNewDocName, _
FileFormat:=wdFormatDocumentDefault
.Close SaveChanges:=wdDoNotSaveChanges
End With
End If
' Get next source file name
sDocName = Dir
Loop
Next
MsgBox "Finished"
End Sub
2021-06-28 17:06:05
0
赞
赏
本文基于CC BY-NC-ND 4.0 许可协议发布,作者:野生的喵喵。 固定链接: 【vb-office-doc-to-docx】 转载请注明
相关文章:
发表新的评论
文章分类
文章归档
标签
deb ,
,
蓝屏 ,
select ,
html5 ,
tomcat ,
gcc ,
ajax ,
apt-get update ,
选择 ,
js加密 ,
java ,
工作 ,
ocr ,
AngularJs ,
感慨 ,
work ,
click ,
javascript ,
反向代理 ,
ip查询 ,
空间查询 ,
word ,
ECS服务器 ,
centos ,
杂 ,
StartupWMClass ,
前端 ,
js ,
vmdk ,
感概 ,
select2 ,
virtualbox ,
gg代理 ,
share ,
seo ,
风筝 ,
email ,
ASR ,
转换 ,
cool ,
activiti-ui ,
喵小凡 ,
@PropertySource ,
ckeiditor ,
网站攻击 ,
SRILM ,
风景 ,
plugin ,
vdi ,
扩容 ,
chorme ,
阿里云 ,
KALDI ,
num ,
packer2 ,
pic ,
gg镜像 ,
win8.1 ,
ecs ,
mysql ,
Ubuntu ,
快递查询 ,
nginx ,
ubuntu ,
swap ,
maven ,
entropy_avail ,
tencent ,
语音识别 ,
prerender ,
xfce4 ,
进度条 ,
存储过程 ,
activiti ,
熵 ,
日出 ,
练笔 ,
虞美人 ,
nodejs ,
词 ,
demo ,
jquery ,
random ,
linux ,
cat ,
bootstrapValidator ,
angularJs ,
live ,
on ,
gg ,
雪 ,
婚姻 ,
景色 ,
@Autowired ,
pdf ,
emqttd ,
优化 ,
thchs30 ,
opencv ,