Results 1 to 8 of 8

Thread: Help required to extract data in Word doc to Excel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Word tables with merged cells are a pain to process, however the attached Word add-in (not yet published on my web site) will identify the cell indices of the cells in such a table to make it simpler to address the cell content directly using Word VBA. e.g. running the code from Outlook, you can grab the contents of the required cells and write them to your workbook. The following example assumes your document is open and active in Word. In practice you would open the document(s) from the macro to process them.

    Dim wdApp As ObjectDim wdDoc As Object
    Dim oCell As Object
        On Error Resume Next
        Set wdApp = GetObject(, "Word.Application")
        If Err Then
            Set wdApp = CreateObject("Word.Application")
        End If
        On Error GoTo 0
        Set wdDoc = wdApp.activedocument    ' or open the document
        Set oCell = wdDoc.Tables(1).Range.Cells(3).Range
        oCell.End = oCell.End - 1
        'do something with ocell.text
        MsgBox "Site Name is " & oCell.Text
    Attached Files Attached Files
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •