![]() |
#1
|
|||
|
|||
![]()
Some years ago, someone here wrote me a macro to copy just the tables in a Word document and paste then into a new one. The purpose of this is to be able to reformat these tables with a custom table style and apply para styles, as necessary, local formatting, before replacing the tables in the original document with the new ones.
A further step that could be very useful would be replacing the table styles in the new document with the style upon which our custom tables are based, namely, Table Grid. (There are a bunch of MS built-in Table Grid styles, numbered, "light," etc.; I used plain Table Grid, finding it more amenable that Normal.) I am guessing that this action could be added to the existing macro (see below). One additional option that would be nice, if possible, would be a separate action to clear text styles. I say option, because, while usually the simplest path is to strip them all and apply the custom paragraph styles, there are times when in long tables, when text and bulleted paragraphs are frequently interspersed, it can be easier to leave bulleted paragraphs bulleted so that finding them is easier. This action might therefore be set off by apostrophe paragraphs and a description line, so that the user could disable that particular part of the macro when desired. (The only way I know to do this is to start each action line with an apostrophe; I'm assuming it would not be many lines long; I'm no coder.) Would someone be willing to provide this? Code:
Sub CopyTables() Dim Source As Document Dim Target As Document Dim tbl As Table Dim tr As Range Set Source = ActiveDocument Set Target = Documents.Add For Each tbl In Source.Tables Set tr = Target.Range tr.Collapse wdCollapseEnd tr.FormattedText = tbl.Range.FormattedText tr.Collapse wdCollapseEnd tr.Text = vbCrLf Next End Sub |
Tags |
strip styles, table styles |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
strip characters from the right | jon.fallows@sedgman.com | Excel | 3 | 05-09-2018 11:38 PM |
![]() |
ShaunO | Mail Merge | 1 | 08-19-2016 04:20 PM |
![]() |
andrewballem | Word Tables | 2 | 11-12-2013 05:18 AM |
![]() |
jbk1043 | Word | 1 | 03-03-2013 01:46 PM |
![]() |
p3aul | Word | 9 | 08-18-2009 12:42 AM |