Question : How do I import into excel a word document, each line is one word from the document?

I have a word document.  I want to import that word document into excel and have it so that each row in column a contains only one of the words in the document.

Answer : How do I import into excel a word document, each line is one word from the document?

JP,

Sorry, I didn't explain the executing instructions.

I used a docPath variable in the modified code below that you can put path information and execute the script. Following are the steps to follow.

0- Make sure your document is not "opened" already. Not a big problem since code will still work but better close your document to avoid confusion (perhaps completely quit Word).
1- Open a new Excel workbook.
2- Go to VBE (Alt + F11)
3- Insert->Module to insert a new module, it will be appeared at the right pane
4- Copy and paste the provided code into the right pane
5- Change docPath variable with your document's path and name in the pasted code ("C:\DocFolder\WordDocument.doc" for example)
6- Run the macro (in VBA: Run->Run Macro or directly, in Excel Tools->Macro->Macros->select "Word2ExcelColumn" macro and "Run").

It is supposed to open Word and your document if you provided correct file path and name then fill in the column A in the Excel worksheet with the words in your document.
I hope it helps.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Sub Word2ExcelColumn()
Dim wrdapp As Object 'Word.Application
Dim wrddoc As Object 'Word.Document
Dim i As Long
Dim docPath as String 
 
  docPath = "C:\sample.doc"
  Set wrdapp = CreateObject("Word.Application")
  Set wrddoc = wrdapp.Documents.Open(docPath, , True)
  wrdapp.Visible = True
  Application.ScreenUpdating = False
  For i = 1 To wrddoc.words.Count
    ActiveSheet.Cells(65536, 1).End(xlUp).Offset(1).Value = wrddoc.words.Item(i)
  Next i
  Application.ScreenUpdating = True
End Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us