getting data from word into excel

N

Nicolas Roth

Hello,
I have the following issue: i'd like, from excel, to open a word file,
copy the entire content (plain text), and then copy it into a text box
in excel.
I have written the following code, however nothing happens when I
execute it and I can't find what is wrong.. Thanks for your help,
Nicolas

Public Sub DonnéesWordVersExcel()


Dim wdDoc As Word.Document
Dim AppWord As Word.Application



Set AppWord = New Word.Application

AppWord.ShowMe
AppWord.Visible = True

Set wdDoc = AppWord.Documents.Open("c:\hello.doc", ReadOnly:=False)

With AppWord
.Selection.WholeStory
myTxt = .Selection
End With

Windows("wordtest.xls").Activate
Sheets("Sheet1").Activate

ActiveSheet.Shapes("Text Box 16").Select
Selection.Characters.Text = myTxt
Cells(16, 2).Select
'ThisWorkbook.Worksheets("Sheet1").Paste

AppWord.Application.Quit


End Sub
 
C

Charalampos

Try this (with TextFrame)

Sub DonneesWordVersExcel()

Dim wdDoc As Word.Document
Dim AppWord As Word.Application


Set AppWord = New Word.Application


AppWord.ShowMe
AppWord.Visible = True


Set wdDoc = AppWord.Documents.Open("c:\hello.doc", ReadOnly:=False)


With AppWord
.Selection.WholeStory
myTxt = .Selection
End With

ThisWorkbook.Activate

ActiveSheet.Shapes("Text Box 16").TextFrame.Characters.Text = myTxt
Cells(16, 2).Select
'ThisWorkbook.Worksheets("Sheet1").Paste

AppWord.Application.Quit

End Sub
 

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