title: Search word doc for text and paste into excel file
body: <p>I'm pretty sure I'm real close on this one, I used a combination of <a href="https://stackoverflow.com/questions/7338385/how-can-i-copy-one-section-of-text-from-word-to-excel-using-an-excel-macro">this question for text selection</a> and <a href="https://stackoverflow.com/questions/12245525/how-to-preserve-source-formatting-while-copying-data-from-word-table-to-excel-sh">this other question regarding importing tables</a> for what I've gotten so far. </p>
  
  <p>I'm trying to find certain value in a word file, with the most identifiable preceding text being a "VALUE DATE" on the line above it. The value I want is in the line below this "VALUE DATE". I want the macro to be able to search the word doc for the desired text and paste it into excel, as normally we would have to do this manually about 50 times. Very tedious.</p>
  
  <p>For reference here's what the text looks like in the word doc.</p>
  
  <pre><code>  TRANSACTIONS              VALUE DATE
                                31-08-15                            X,XXX.XX
  </code></pre>
  
  <p>I want to pull value X,XXX.XX and paste it into a destination in excel, let's just use A1 for simplicity.</p>
  
  <pre><code>Sub wordscraper9000()
      Dim oWordApp As Object, oWordDoc As Object
      Dim FlName As String
      '''''dim tbl as object  --&gt; make string
      Dim TextToFind As String, TheContent As String
      Dim rng1 As Word.Range
      FlName = Application.InputBox("Enter filepath of .doc with desired information")
      'establish word app object
      On Error Resume Next
      Set oWordApp = GetObject(, "Word.application")
      If Err.Number &lt;&gt; 0 Then
          Set oWordApp = CreateObject("Word.application")
      End If
      Err.Clear
      On Error GoTo 0
      oWordApp.Visible = True
      'open word doc
      Set oWordDoc = oWordApp.documents.Open(FlName)
          '--&gt; enter something that will skip if file already open
      '''''set tbl = oworddoc.tables(1) --&gt; set word string
      'declare excel objects
      Dim wb As Workbook, ws As Worksheet
      'Adding New Workbook
      Set wb = Workbooks.Add
      'Saving the Workbook
      ActiveWorkbook.SaveAs "C:\Users\iansch\Desktop\DummyWB.xlsx"
      Set ws = wb.Sheets(1)
      'what text to look for
      TextToFind = "VALUE DATE"
      '''''problems here below
      Set rng1 = oWordApp.ActiveDocument.Content
      rng.Find.Execute findtext:=TextToFind, Forward:=True
      If rng1.Find.found Then
          If rng1.Information(wdwithintable) Then
              TheContent = rng.Cells(1).Next.Range.Text 'moves right on row
          End If
      Else
          MsgBox "Text '" &amp; TextToFind &amp; "' was not found!"
      End If
      'copy text range and paste into cell A1
      'tbl.range.copy
      ws.Range("A1").Activate
      ws.Paste
  End Sub
  </code></pre>
  
  <p>At the line</p>
  
  <pre><code>set rng1.oWordApp.ActiveDocument.Content
  </code></pre>
  
  <p>I get a run-time 8002801d error - automation error, library not registered.</p>
  
  <p>I couldn't find anything on here that was perfect for my case, however the 2nd question I linked to is very, very close to what I want, however I'm trying to import text rather than a table.</p>