7,785
社区成员




Dim wordApp As New Microsoft.Office.Interop.Word.Application
Dim wordDoc As New Microsoft.Office.Interop.Word.Document
wordDoc = wordApp.Documents.Open(DirListBox1.Path & "\" & fileArrayComList(i, 0)) '打开文件并赋予文件实例
If Err.Number = 462 Then
wordApp = CreateObject("Word.Application") '建立WORD实例
wordDoc = wordApp.Documents.Open(DirListBox1.Path & "\" & fileArrayComList(i, 0)) '打开文件并赋予文件实例
End If
Dim stringDoc = wordDoc.Range.Text
Do While InStr(stringDoc, Chr(10) & Chr(13)) > 0
stringDoc = stringDoc.replace(Chr(13), "<br><br> ")
Loop
stringDoc = stringDoc.replace(" ", " ")
stringDoc = stringDoc.replace(" ", "")
stringDoc = stringDoc.replace("'", "‘")
'MsgBox(stringDoc)
wordDoc.Close() '关闭文档实例
wordApp.Quit()
wordDoc = Nothing
wordApp = Nothing
'模块代码
Type docit
name As String
paragraph As Long
allcount As Long
reblank As Long
resign As Long
End Type
'主程序代码
Dim itemDoc As docit
Dim stringDoc As String
Dim k As Integer
Dim wordCount()
Dim wordApp As New Word.Application
Dim wordDoc As New Word.Document
Dim wordArange As Word.Range
Dim wordSelection As Word.Selection
Dim ReplaceSign As Boolean
's为文件名及地址
On Error Resume Next
Set wordDoc = wordApp.Documents.Open(s) '打开文件并赋予文件实例
If Err.Number = 462 Then
Set wordApp = CreateObject("Word.Application") '建立WORD实例
Set wordDoc = wordApp.Documents.Open(s) '打开文件并赋予文件实例
End If
On Error GoTo ss
'itemDoc.name = wordDoc.Words.Parent
stringDoc = wordDoc.Range.Text
itemDoc.paragraph = 0
itemDoc.allcount = Len(stringDoc)
wordDoc.Close '关闭文档实例