Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extracting Data from Word to Excel.
I need to copy data from one cell in a table from a Word document into an
Excel spreadsheet. Can anyone respond with tips (or sample code) that can help with this? Thank you! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extracting Data from Word to Excel.
jk
Here's one way Sub GetDataFromWord() 'Set a reference (Tools - References) to the 'Microsoft Word x.0 Object Library Dim wdApp As Word.Application Dim wdDoc As Word.Document Dim sFile As String Dim rInput As Range 'Define row and column of data in table Const lROW As Long = 2 Const lCOL As Long = 2 'Specify file that contains table sFile = "C:\Dick\NG\01 Jan\GetData.doc" 'instantiate Word and open document Set wdApp = New Word.Application Set wdDoc = wdApp.Documents.Open(sFile) 'define range where data goes Set rInput = Sheet1.Range("a1") 'Copy value from table and paste to cell With wdDoc.Tables(1) .Cell(lROW, lCOL).Range.Copy rInput.PasteSpecial xlPasteValues End With wdDoc.Close False wdApp.Quit Set wdDoc = Nothing Set wdApp = Nothing End Sub -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com jk wrote: I need to copy data from one cell in a table from a Word document into an Excel spreadsheet. Can anyone respond with tips (or sample code) that can help with this? Thank you! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Extracting Data from Word to Excel.
That worked great!
Thank you!! "Dick Kusleika" wrote: jk Here's one way Sub GetDataFromWord() 'Set a reference (Tools - References) to the 'Microsoft Word x.0 Object Library Dim wdApp As Word.Application Dim wdDoc As Word.Document Dim sFile As String Dim rInput As Range 'Define row and column of data in table Const lROW As Long = 2 Const lCOL As Long = 2 'Specify file that contains table sFile = "C:\Dick\NG\01 Jan\GetData.doc" 'instantiate Word and open document Set wdApp = New Word.Application Set wdDoc = wdApp.Documents.Open(sFile) 'define range where data goes Set rInput = Sheet1.Range("a1") 'Copy value from table and paste to cell With wdDoc.Tables(1) .Cell(lROW, lCOL).Range.Copy rInput.PasteSpecial xlPasteValues End With wdDoc.Close False wdApp.Quit Set wdDoc = Nothing Set wdApp = Nothing End Sub -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com jk wrote: I need to copy data from one cell in a table from a Word document into an Excel spreadsheet. Can anyone respond with tips (or sample code) that can help with this? Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Extracting the last word from a string. | Excel Worksheet Functions | |||
Extracting specific data from inconsistant multiple word documents | Excel Discussion (Misc queries) | |||
Extracting All But Last Word | Excel Worksheet Functions | |||
Extracting info from word and displaying in an excel spreadsheet | Excel Discussion (Misc queries) | |||
Extracting whole word from cell | Excel Programming |