Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default 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   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting the last word from a string. Ciarán Excel Worksheet Functions 2 March 19th 10 02:21 PM
Extracting specific data from inconsistant multiple word documents Matt Bennette[_2_] Excel Discussion (Misc queries) 4 January 5th 09 01:30 PM
Extracting All But Last Word Steve Madden Excel Worksheet Functions 2 January 16th 06 05:22 PM
Extracting info from word and displaying in an excel spreadsheet Drew Excel Discussion (Misc queries) 0 March 7th 05 03:49 AM
Extracting whole word from cell Leo Excel Programming 3 January 15th 04 02:52 PM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"