ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting data from word into excel (https://www.excelbanter.com/excel-programming/349186-getting-data-word-into-excel.html)

Nicolas Roth

getting data from word into excel
 
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


Charalampos

getting data from word into excel
 
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



All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com