![]() |
|
#1
|
|||
|
|||
|
Allen Wyatt posted this useful macro on WordTips.net quite a while ago. I would like an addition to it that will, after pasting, strip all styles from the tables, including table styles. I would normally use Ctrl+spacebar, Ctrl+Q, and Alt+Ctrl+u.
This would be useful for anyone needing to bring the tables from another document into one in, for instance, a custom template with its own table styles. I'm sure this is a simple matter for someone who knows VBA, and I thank him or her in advance. 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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Adding a save as macro button to a template
|
nparsons75 | Word | 6 | 01-08-2016 07:47 AM |
VBA Code for adding Macro to QAT
|
OTPM | Project | 4 | 08-22-2013 01:33 PM |
Adding macro to normal.dotm programmatically
|
etippelt | Word VBA | 6 | 04-08-2013 05:55 PM |
| Adding Macro menu to the right click menu (Word 2007) | masam123 | Word | 0 | 10-14-2011 04:05 AM |
| Macro for automatically adding filename without .doc | RPM7 | Word VBA | 0 | 04-29-2010 01:43 AM |