随笔 - 12  文章 - 0  trackbacks - 0
<2018年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(103)

随笔档案

文章档案

jQuery

搜索

  •  

最新评论

阅读排行榜

评论排行榜

Public Sub Rdoc() If testing Then Exit Sub On Error GoTo ErrorHandler Dim currentRow As Integer currentRow = ActiveCell.row Dim dateStr As String dateStr = format(Date, "yyyyMMdd") Dim localPath As String localPath = Cells(currentRow, 9) Dim filePath As String Dim wa As Variant Dim wd As Word.document If InStr(Cells(currentRow, 11), ".doc") > 0 Then filePath = Cells(currentRow, 9) & Cells(currentRow, 11) Set wa = CreateObject("Word.Application") wa.Visible = False Set wd = wa.Documents.Open(filePath) Cells(currentRow, 10) = wd.Content.text wd.Close savechanges:=False wa.Quit Set wa = Nothing Else Dim wildcard As String wildcard = "*.doc*" Dim fileText As String Dim fso As Object Dim objFolder As Object Dim myFolder As Object Dim myFile As Object Set fso = CreateObject("Scripting.FileSystemObject") If fso.FolderExists(localPath) Then Set objFolder = fso.getfolder(localPath) For Each myFolder In objFolder.SubFolders For Each myFile In myFolder.files If myFile.Name Like wildcard Or myFile.Name = wildcard Then 'MsgBox myFile.path Set wa = CreateObject("Word.Application") wa.Visible = False Set wd = wa.Documents.Open(myFile.path) fileText = fileText & wd.Content.text wd.Close savechanges:=False wa.Quit Set wa = Nothing End If Next Next Set objFolder = Nothing End If Set fso = Nothing Cells(currentRow, 10) = Cells(currentRow, 10) & fileText End If ErrorHandler: If Err.Number <> 0 Then MyMsgBox Err.Number & " " & Err.Description, 10 End If End Sub
posted on 2018-12-27 10:21 萍水相逢 阅读(124) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: