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!

How to: read each lines of my .doc... 1

Status
Not open for further replies.

bluelive

Programmer
Oct 21, 2003
8
BE
Hi,

I would like to know how to open a word document and do the folowing (via a word macro):

1. From the top to the end, read each line and store to an array
2. Search for any tables and copy them to the clipboard
3. From Word (VBA code), create an excel sheet and paste each items of my array on cell(i), cell(i +n)...
4. Paste tables from the clipbaord and catch the original layout + format.

Is it possible or not ? (lines code example very well come)
 
No need for the array (it wouldn't store the text formatting). The following snippet of code will take the paragraph in Word with the cursor in it, and copy it into an Excel cell:

set xl=getobject(,"excel.application")
selection.Paragraphs(1).Range.copy
with xl.activeworkbook.activesheet
.range("A1").activate
.paste
end with

If this works for you, you could adapt it into a loop that traverses through each paragraph in Word. The tables are a little trickier (for one, where do you want them to go in Excel?)



Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top