VBA读取word中的内容到Excel中

2022-12-29,,,,

原文:VBA读取word中的内容到Excel中
Public Sub Duqu()
     Dim myFile As String
    Dim docApp As Word.Application
    Dim docRange As Word.Range
    myFile = ThisWorkbook.Path & "\Word文档的名字"    '指定Word文档
    Set docApp = New Word.Application
    docApp.Documents.Open myFile
    For i = 1 To docApp.ActiveDocument.Paragraphs.Count
    With docApp.ActiveDocument
        'If .Paragraphs.Count >= 4 Then
            Set docRange = .Paragraphs(i).Range
            cp = cp & docRange
            
        'End If
    End With
      
    Next i
    Range("a1") = cp
    docApp.Quit
    Set docRange = Nothing
    Set docApp = Nothing
    Set ws = Nothing
    
End Sub

VBA读取word中的内容到Excel中的相关教程结束。

《VBA读取word中的内容到Excel中.doc》

下载本文的Word格式文档,以方便收藏与打印。