![]() |
|
#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] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jamal NUMAN | Word | 24 | 09-06-2017 12:18 PM |
![]() |
HalinQuincy | Word Tables | 4 | 04-03-2011 04:11 PM |
![]() |
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 |