|
江湖救急,等着要呢。。先谢过高手们了
要求是这样的:将word文档的文本内容控件和组合内容控件的内容提取到excel的指定单元格。先些过高手们了,最好能调取当前文件夹的所有文档,要是这样很麻烦的话,就一个也可以。。。。谢谢 了
- Dim EAPP,WAPP,TempWb,i,ConControl,Shell,ObjectPath,FolderPath,FSO,FSOFolder,FSOFile
- On Error resume next
- Set EAPP=CreateObject("Excel.Application")
- EAPP.Visible=True
- Set Tempwb=EAPP.workbooks.Add
- Set WAPP=CreateObject("WORD.Application")
- Set Shell=CreateObject("Shell.Application")
- Set ObjectPath=Shell.BrowseForFolder(0, "请选择Word文件所在的文件夹", 0, 0)
- If ObjectPath Is Nothing Then
- Wscript.Quit
- End If
- FolderPath=ObjectPath.Self.Path
- Set FSO=CreateObject("Scripting.FileSystemObject")
- Set FSOFolder=FSO.GetFolder(FolderPath)
- For Each FSOFile In FSOFolder.Files
- i=i+1
- j=0
- WAPP.Documents.open(FSOFile.Path)
- For Each ConControl in WAPP.ActiveDocument.ContentControls
- j=j+1
- TempWb.sheets(1).cells(i,j)=ConControl.Range
- Next
- WAPP.ActiveDocument.Close
- Next
- Msgbox "已完成"&FolderPath&"Word文档的汇总"
- WAPP.Quit
复制代码
|
|