Parse a word document into an excel file

后端 未结 2 878
感情败类
感情败类 2021-01-24 12:50

I have a word document that has data that I would like to parse into an excel file. The source files are hundreds of pages long. I have been working with VBA, but I just start

2条回答
  •  Happy的楠姐
    2021-01-24 13:12

    Here is code that actually works.

    'Create a New Object for Microsoft Word Application
    Dim objWord As New Word.Application
    'Create a New Word Document Object
    Dim objDoc As New Word.Document
    'Open a Word Document and Set it to the newly created object above
    Set objDoc = objWord.Documents.Open(Filename:=DocFilename, Visible:=False)
    
    Dim strSingleLine As Paragraph
    Dim strLineText As String
    
    For Each strSingleLine In objDoc.Paragraphs
        strLineText = strSingleLine.Range.Text
        'Do what you've gotta do
    Next strSingleLine
    

提交回复
热议问题