Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you Export from word to Excel using VBA??

Status
Not open for further replies.

Excelerate2004

Programmer
Mar 8, 2004
163
CA
Hello all,

I took a quick scan thru the archives but didnt see anything relating to what I'm trying to do. So I decided to post here.

I'm trying to export text from a word document using VBA to Excel. I tried running a macro but it didnt quite give me what I wanted.

I'd like to be able to export the first line of a "paragraph" and place that in a cell in a column in an excel sheet.

Then export similar paragraphs throughout the word doc to excel.

Is there a resource I can find on this procedure? I've also checked the net and havent been able to come up with anything useful.


Thanks for any help I can get!
 
You can iterate through Words 'sentences' object for each sentence outputting it into a new cell in XL.

Try this piece of VBA code ...


Sub test()
Dim iSentence As Integer
Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook

Set appExcel = New Excel.Application
Set wbExcel = appExcel.Workbooks.Add
appExcel.Visible = True
For iSentence = 1 To ThisDocument.Sentences.Count

wbExcel.Sheets(1).Range("A" & iSentence).Value = ThisDocument.Sentences(iSentence)

Next


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top