Copy from WORD to EXCEL using a macro.....

G

Guest

I have the following macro that opens a word document from excel..

*****************************************************

'Sub OpenWord()

'
' OpenWord Macro
' Macro recorded 28/02/2006 by rivers
'


Set appWd = CreateObject("Word.Application")
appWd.Visible = True

ChDir "S:\PROJECTS\Paypoint-zone"

appWd.Documents.Open FileName:="S:\PROJECTS\Paypoint-zone\Invoice.rtf"

'End Sub


****************************************************

This opens word and the document "invoice".

I would like to know if anyone knows how I can write a macro to copy the
text in the word document into my excel spreadsheet that is open???????

(I usually do this by highlighting the text on the word doc and doing an
edit/paste special.)

Then close the word document and return to the excel spreadsheet....

HHHHHEEEEEEEELLLLLLLLPPPPPPPPP.................................
 
S

Steve Yandl

How is the text organized in the Word document? You can return any or all
of the text without using copy/paste or even having the Word document
visible. You generally have to do some text manipulation because you will
import things like end of paragraph marks that will appear as odd characters
in Excel but it is generally simple enoug to handle. Below is an example
that will bring all the text in the body of the document into cell A1.

Sub GrabFromWord()
Set objWd = CreateObject("Word.Application")
Set objDoc = objWd.Documents.Open("C:\Test\TestB.doc")
Set myRange = objDoc.Range(0, 0)
myRange.WholeStory
strStory = myRange.Text
Cells(1, 1).Value = strStory
objDoc.Close
objWd.Quit
Set objWd = Nothing
End Sub


Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top