![]() |
|
|
|
#1
|
|||
|
|||
|
I have a number of word documents, each contains about 30 tables. My task is to copy all the tables into a spreadsheet (easy), and then to make a list of table titles (don't know how to do). Each document is structured so that table title is a sentence (or a one-sentence paragraph) that immediately precedes the table.
The first part I solve by using i = ...tables.count and then copying and pasting each table into a spreadsheet Any hints on how to find and copy a sentence that precedes each table? |
|
#2
|
||||
|
||||
|
Hi pav,
For each table, you could insert a new top row, merge all cells in that row, then copy the preceding sentence into it. For example: Code:
Dim oTbl As Table, Rng As Range
With ActiveDocument
For Each oTbl In .Tables
With oTbl
Set Rng = .Range.Paragraphs.First.Previous.Range
Rng.End = Rng.End - 1
Rng.Cut
Rng.Characters.Last.Delete
.Rows.Add BeforeRow:=.Rows.First
.Rows.First.Cells.Merge
.Cell(1, 1).Range.Paste
End With
Next
End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to have the location (path) of the Word document on the title bar?
|
Jamal NUMAN | Word | 24 | 09-06-2017 12:18 PM |
cell of one table to display in a second table
|
HalinQuincy | Word Tables | 4 | 04-03-2011 04:11 PM |
Help With Table
|
ABB | Word Tables | 1 | 12-13-2010 02:46 PM |
| Pasting table in Photoshop cutting off table | azdolfan | Word Tables | 0 | 05-16-2010 01:52 PM |
| table help | corkus | Word Tables | 5 | 11-18-2009 07:15 AM |