Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Data From Word Into Excel

Status
Not open for further replies.

AnotherHiggins

Technical User
Nov 25, 2003
6,259
US
It turns out that a department has been tracking parts-ordered on Word documents. that's a step up from paper, I suppose.

Now they need to see some reporting against this data.

So here's what I'm thinking:

I'll put all of the word files into a single folder. I can loop through every file in the folder and pull data into a single spreadsheet.

I can cover the looping bit, but I've never done any VBA in/against Word and could really use some help.

Any ideas?

ps - I tried uploading an example document to box.net to share here, but I'm having trouble uploading anything.... Might be a firewall issue. I'll try again later if needed.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
It sounds like you want to be in Excel and your (Excel) macro will open and manipulate Word. If so:
Set appWD = CreateObject("Word.Application")
appWd.Visible = True
appWd.documents.open([red]<fully qual'd filename>[/red])

will load up a document.

Now I guess you want to copy certain data from the document and paste into Excel? You need to specify a little more.

_________________
Bob Rashkin
 




John,

Is the data in Word in tables?

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thanks, Bong.

Skip - Yes. There are 6 different tables in the Word document with between 1 and 16 rows.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 




Building on Bob's suggestion...
Code:
    Dim appWd As Word.Application, oDOC As Word.Document, lNextRow As Long
    Dim oTB As Word.Table
    Set appWd = CreateObject("Word.Application")
    appWd.Visible = True
    Set oDOC = appWd.documents.Open("C:\Documents and Settings\ii36250\My Documents\JohnsDoc.doc")

    For Each oTB In oDOC.Tables
        oTB.Range.Copy
        lNextRow = Sheet1.[A1].CurrentRegion.Rows.Count + 1
        Sheet1.Cells(lNextRow, "A").PasteSpecial xlPasteValues
    Next
    oDOC.Close
    Set oDOC = Nothing
    appWd.Quit
    Set appWd = Nothing
assuming that the tables are congruous.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top