把下面的代码保存成一个word.hta,然后运行即可:
<script language=vbs>
'
' 杨小波于11:15 2006-10-29
'__________________
dim wdobj
dim baogao
'------------------
sub main
Const WINDOW_HANDLE = 0
Const OPTIONS = &H10&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", OPTIONS)
If objFolder Is Nothing Then
exit sub
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
divT=""
pageNmus=0
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace (objpath)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim arrHeaders(13)
'For i = 0 to 13
arrHeaders(13) = objFolder.GetDetailsOf (objFolder.Items, 13)
'Next
For Each strFileName in objFolder.Items
'For i = 0 to 13
filnm=objFolder.GetDetailsOf (strFileName, 0)
If true and right(filnm,4)=".doc" then
pg=objFolder.GetDetailsOf (strFileName, 13)
pagenums=pagenums + cint(pg)
divt=divt & "<td>" & filnm & "</td><td>" & pg & "</td></tr>"
End If
' Next
Next
jieguo.innerhtml="<table width=100%><tr><td width=70%><b>文件名</b></td><td><b>合计" & pagenums & "页</b></td></tr><tr>" & divt & "</table>"
end sub
'_______________________
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p align=center size=3>
<b>同目录Word文档页码统计报表</b><br>
<input type=button name="Cmd" value="选择目录" onclick="main"><br></p><hr>
</font>
<div id=jieguo></div><br>
</body>