应以为小朋友要求,写了一个简单高效批处理,供大家使用
' 2>nul 3>nul&cls&@echo off
'&dir /a-d/b/s *.doc or *.docx|cscript -nologo -e:vbscript "%~fs0"
'&exit /b
call test
Sub test()
Set wd = CreateObject("Word.application")
'wd.Visible = True
Set fso = CreateObject("scripting.filesystemobject")
Do While WSH.StdIn.AtEndOfStream <> True
file = WSH.StdIn.ReadLine
Set ff = fso.GetFile(file)
If ff.Attributes <> 32 Then
ff.Attributes = 32
End If
WSH.Echo file
If Left(ff.shortname, 2) <> "~$" Then
Set doc = wd.Documents.Open(file)
If doc.ProtectionType = -1 Then '如果是没保护
For Each oSection In doc.Sections