ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   grabbing data from MS Word (https://www.excelbanter.com/excel-programming/337655-grabbing-data-ms-word.html)

nims

grabbing data from MS Word
 

I'm trying to create code for excel that will allow me to open a series
of word documents, copy certain rows from tables in those docs, and
paste them into the excel worksheet.

The main problem I'm having is with formatting. I am able to paste the
data in Excel, but there are characters added for spaces in the cells.

Here is my code:

Dim oWrd As Object
Set oWrd = CreateObject("Word.Application")

Dim oDoc As Object
Set oDoc = CreateObject("Word.Document")

Set oDoc = oWrd.Documents.Open("c:\OMA\TIJ_90442.doc")
'oWrd.Visible = False

ActiveWorkbook.Worksheets(1).Cells(6, 1) = oDoc.Tables(1).Rows(1)
ActiveWorkbook.Worksheets(1).Cells(5, 2) = oDoc.Tables(3).Cell(3, 5)

oWrd.Quit
Set oWrd = Nothing


--
nims
------------------------------------------------------------------------
nims's Profile: http://www.excelforum.com/member.php...o&userid=26426
View this thread: http://www.excelforum.com/showthread...hreadid=396941


nims[_2_]

grabbing data from MS Word
 

I figured out how to paste the rows properly, but what is the code I
need so every row is pasted below the previous one?


--
nims
------------------------------------------------------------------------
nims's Profile: http://www.excelforum.com/member.php...o&userid=26426
View this thread: http://www.excelforum.com/showthread...hreadid=396941


nims[_3_]

grabbing data from MS Word
 

I figured that out too! lol!

What I can't seem to do is search a directory and all subdirectories
for .doc files. I can search 1 directory, but I don't know how to
search subdirectories.


--
nims
------------------------------------------------------------------------
nims's Profile: http://www.excelforum.com/member.php...o&userid=26426
View this thread: http://www.excelforum.com/showthread...hreadid=396941


Tom Ogilvy

grabbing data from MS Word
 
http://support.microsoft.com/kb/185476/EN-US/
How To Search Directories to Find or List Files

http://support.microsoft.com/kb/185601/EN-US/
HOW TO: Recursively Search Directories by Using FileSystemObject

http://support.microsoft.com/kb/186118/EN-US/
How To Use FileSystemObject with Visual Basic

--
Regards,
Tom Ogilvy


"nims" wrote in message
...

I figured that out too! lol!

What I can't seem to do is search a directory and all subdirectories
for .doc files. I can search 1 directory, but I don't know how to
search subdirectories.


--
nims
------------------------------------------------------------------------
nims's Profile:

http://www.excelforum.com/member.php...o&userid=26426
View this thread: http://www.excelforum.com/showthread...hreadid=396941





All times are GMT +1. The time now is 09:37 AM.

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