LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Load data from Word into Excel

Hi Robert,

Am Thu, 2 May 2013 13:56:01 -0700 schrieb Robert Crandal:

What does your final code look like for this entire
function?


Sub ImportFromWord()

Dim objWord As Object
Dim oTable As Table
Dim oRow As Row
Dim r As Integer

' Load target Word document
Set objWord = CreateObject("Word.Application")
objWord.documents.Open ("C:\Users\Claus Busch\Desktop\Test.docx")
objWord.Visible = True
objWord.Activate

Set oTable = objWord.ActiveDocument.Tables(1)

' Go through all rows of Word table
For r = 1 To oTable.Rows.Count
Set oRow = oTable.Rows(r)

' Paste data back into Excel. This Word table has 6 columns
Sheet1.Cells(r, 1).Value = oRow.Cells(1).Range.Text
Sheet1.Cells(r, 2).Value = oRow.Cells(2).Range.Text
Sheet1.Cells(r, 3).Value = oRow.Cells(3).Range.Text
Sheet1.Cells(r, 4).Value = oRow.Cells(4).Range.Text
Sheet1.Cells(r, 5).Value = oRow.Cells(5).Range.Text
Sheet1.Cells(r, 6).Value = oRow.Cells(6).Range.Text
Next r

For r = 1 To 6
Columns(r).TextToColumns Destination:=Cells(1, r), _
DataType:=xlDelimited, Tab:=True, fieldinfo:=Array(1, 1)
Next

' Quit Word
objWord.Application.Quit
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
 
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
How to load data into excel? Eric Excel Discussion (Misc queries) 3 March 9th 09 04:23 PM
Saving excel data to load into word TJA Excel Worksheet Functions 1 February 29th 08 12:18 PM
Cannot load Excel 2000 Addin from Word (and that's so weird!) Montezuma Excel Programming 0 January 18th 07 11:43 AM
Is anything needed if I only load Word & Excel from Office XP Sta. Art SC Excel Discussion (Misc queries) 0 January 26th 05 01:59 AM
opening a word document from excel: file still won't load chris Excel Programming 2 April 1st 04 12:05 PM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"