Excel text import wizard rows
ObjWord.Visible = True 'Word document object “objWord.Documents(WordNam).Sentences.Count” can return the total number of sentences. We can retrieve one sentence after another using for loop based on the structure. It looks like that the poem is consists of a lot of sentences.
#Excel text import wizard rows how to
Let’s look back at the Fixed-width option part and see how to retrieve that poem into excel. ObjWord.Quit SaveChanges:=wdDoNotSaveChanges 'MsgBox objWord.Documents(WordNam).Footnotes.Count 'MsgBox objWord.Documents(WordNam).ActiveWindow.Panes(1).Pages.Count 'MsgBox objWord.Documents(WordNam).Sections.Count 'MsgBox objWord.Documents(WordNam).ActiveWindow.Panes(1).Pages(1).Breaks.Count 'MsgBox objWord.Documents(WordNam).Content 'MsgBox objWord.Documents(WordNam).Comments(1) 'MsgBox objWord.Documents(WordNam).Comments.Count 'MsgBox objWord.Documents(WordNam).Characters(2) 'MsgBox objWord.Documents(WordNam).Characters.Count 'MsgBox objWord.Documents(WordNam).Bookmarks(1) MsgBox objWord.Documents(WordNam).Bookmarks.Count 'MsgBox objWord.Documents(WordNam).Words(40) 'MsgBox objWord.Documents(WordNam).Tables.Count 'MsgBox objWord.Documents(WordNam).Paragraphs.Count 'MsgBox objWord.Documents(WordNam).Sentences(3) 'MsgBox objWord.Documents(WordNam).Sentences.Count ObjWord.Visible = True Dim WordNam As String
Because this document is simple and objects such as TOC, comment, table are not included.ĭim objWord As Object Set objWord = CreateObject( "Word.Application") I recommend you to replace “E:\Fixed Width.docx” and use your own word document.
You can run the code and see what will happen.
Read More: How to pull/extract data from a website into Excel automatically? The following code give you a brief summary of document objects that you can manipulate via VBA. “Thisworkbook.worksheets(2).cells(1,1) = objWord.Documents(WordNam).Sentences(1)” will enable you to extract the first sentence into cell A1 in the second worksheet. You can use Msgbox statement to prompt extracted information or put the extracted information directly into an Excel file. “objWord.Documents(WordNam).Sentences.Count” can enable you to know how many sentences in this word document.
#Excel text import wizard rows full
For example, “objWord.Documents(WordNam).Path” can retrieve the document’s full pathname. By referring to this page, you can know which objects can be manipulated. Here is a list of document objects on this web page. ObjWord.Quit SaveChanges:=wdDoNotSaveChanges Word document objects